/**
 * Venue Events Manager — application theme & layout
 * Built on Bootstrap 5 with local assets (no Vite required).
 */

:root {
    --vem-primary: #0f4c5c;
    --vem-primary-dark: #0a3642;
    --vem-primary-light: #1a6b7d;
    --vem-accent: #e36414;
    --vem-accent-hover: #c9560f;
    --vem-bg: #f3f6f8;
    --vem-surface: #ffffff;
    --vem-sidebar-bg: #0a3642;
    --vem-sidebar-text: rgba(255, 255, 255, 0.82);
    --vem-sidebar-muted: rgba(255, 255, 255, 0.55);
    --vem-sidebar-active: rgba(227, 100, 20, 0.18);
    --vem-sidebar-border: rgba(255, 255, 255, 0.08);
    --vem-header-height: 60px;
    --vem-sidebar-width: 260px;
    --vem-text: #2c3e50;
    --vem-text-muted: #6c7a89;
    --vem-border: #dde4ea;
    --vem-shadow: 0 1px 3px rgba(15, 76, 92, 0.08);
    --vem-shadow-lg: 0 8px 24px rgba(15, 76, 92, 0.12);

    --bs-primary: var(--vem-primary);
    --bs-primary-rgb: 15, 76, 92;
    --bs-link-color: var(--vem-primary);
    --bs-link-hover-color: var(--vem-primary-dark);
    --bs-body-bg: var(--vem-bg);
    --bs-body-color: var(--vem-text);
    --bs-border-color: var(--vem-border);
    --bs-font-sans-serif: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Bootstrap overrides */
.btn-primary {
    --bs-btn-bg: var(--vem-primary);
    --bs-btn-border-color: var(--vem-primary);
    --bs-btn-hover-bg: var(--vem-primary-dark);
    --bs-btn-hover-border-color: var(--vem-primary-dark);
    --bs-btn-active-bg: var(--vem-primary-dark);
    --bs-btn-active-border-color: var(--vem-primary-dark);
}

.btn-accent,
.btn-outline-accent {
    --bs-btn-color: var(--vem-accent);
    --bs-btn-border-color: var(--vem-accent);
    --bs-btn-hover-bg: var(--vem-accent);
    --bs-btn-hover-border-color: var(--vem-accent);
    --bs-btn-hover-color: #fff;
}

.btn-accent {
    --bs-btn-bg: var(--vem-accent);
    --bs-btn-border-color: var(--vem-accent);
    --bs-btn-color: #fff;
    --bs-btn-hover-bg: var(--vem-accent-hover);
    --bs-btn-hover-border-color: var(--vem-accent-hover);
}

.bg-primary-subtle {
    background-color: rgba(15, 76, 92, 0.1) !important;
}

.text-accent {
    color: var(--vem-accent) !important;
}

/* Base */
html, body {
    min-height: 100%;
}

body.vem-app {
    background: var(--vem-bg);
    color: var(--vem-text);
    font-size: 0.9375rem;
}

a {
    text-decoration: none;
}

/* Layout shell */
.vem-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    width: var(--vem-sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--vem-sidebar-bg) 0%, var(--vem-primary-dark) 100%);
    color: var(--vem-sidebar-text);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--vem-sidebar-border);
    transition: transform 0.25s ease;
}

.vem-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    min-height: var(--vem-header-height);
    border-bottom: 1px solid var(--vem-sidebar-border);
}

.vem-sidebar-brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--vem-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.vem-sidebar-brand-text {
    line-height: 1.2;
}

.vem-sidebar-brand-text strong {
    display: block;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
}

.vem-sidebar-brand-text small {
    color: var(--vem-sidebar-muted);
    font-size: 0.72rem;
}

.vem-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.65rem 1.5rem;
}

.vem-nav-section {
    margin-top: 0.5rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--vem-sidebar-muted);
}

.vem-nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    margin-bottom: 2px;
    border-radius: 8px;
    color: var(--vem-sidebar-text);
    font-size: 0.875rem;
    transition: background 0.15s, color 0.15s;
}

.vem-nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.vem-nav-link.active,
.vem-nav-link[aria-current="page"] {
    background: var(--vem-sidebar-active);
    color: #fff;
    font-weight: 500;
}

.vem-nav-link .bi {
    width: 1.15rem;
    text-align: center;
    opacity: 0.85;
}

.vem-nav-link.active .bi {
    color: var(--vem-accent);
    opacity: 1;
}

.vem-nav-children {
    margin: 0.15rem 0 0.35rem 0.5rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--vem-sidebar-border);
}

.vem-nav-children .vem-nav-link {
    padding: 0.4rem 0.65rem;
    font-size: 0.8125rem;
}

.vem-nav-toggle {
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
}

.vem-nav-toggle .bi-chevron-down {
    margin-left: auto;
    font-size: 0.75rem;
    transition: transform 0.2s;
}

.vem-nav-toggle[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

.vem-topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 1030;
    height: var(--vem-header-height);
    background: var(--vem-surface);
    border-bottom: 1px solid var(--vem-border);
    display: flex;
    align-items: center;
    padding: 0 1rem 0 0;
    box-shadow: var(--vem-shadow);
}

@media (min-width: 992px) {
    .vem-topbar {
        left: var(--vem-sidebar-width);
    }
}

.vem-topbar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0 0.5rem;
    border: none;
    background: transparent;
    color: var(--vem-text);
    border-radius: 8px;
}

.vem-topbar-toggle:hover {
    background: var(--vem-bg);
}

@media (min-width: 992px) {
    .vem-topbar-toggle {
        display: none;
    }
}

.vem-main {
    min-height: 100vh;
    padding-top: var(--vem-header-height);
}

@media (min-width: 992px) {
    .vem-main {
        margin-left: var(--vem-sidebar-width);
    }
}

.vem-content {
    padding: 1.25rem;
}

@media (min-width: 768px) {
    .vem-content {
        padding: 1.5rem 1.75rem;
    }
}

.vem-footer {
    padding: 1rem 1.75rem 1.5rem;
    color: var(--vem-text-muted);
    font-size: 0.8125rem;
    border-top: 1px solid var(--vem-border);
    margin-top: 2rem;
}

/* Mobile sidebar overlay */
.vem-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1035;
    background: rgba(0, 0, 0, 0.45);
}

@media (min-width: 992px) {
    .vem-sidebar-backdrop {
        display: none !important;
    }
}

@media (max-width: 991.98px) {
    .vem-sidebar {
        transform: translateX(-100%);
    }

    .vem-sidebar.show {
        transform: translateX(0);
    }
}

/* Cards & stats */
.vem-card {
    background: var(--vem-surface);
    border: 1px solid var(--vem-border);
    border-radius: 10px;
    box-shadow: var(--vem-shadow);
}

.vem-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--vem-border);
    background: transparent;
    font-weight: 600;
}

.vem-card-body {
    padding: 1.25rem;
}

.vem-stat-card {
    background: var(--vem-surface);
    border: 1px solid var(--vem-border);
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: var(--vem-shadow);
    height: 100%;
}

.vem-stat-card .stat-label {
    color: var(--vem-text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.vem-stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--vem-primary);
    line-height: 1.2;
    margin-top: 0.35rem;
}

.vem-stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 76, 92, 0.1);
    color: var(--vem-primary);
    font-size: 1.25rem;
}

.vem-stat-card.accent .stat-value {
    color: var(--vem-accent);
}

.vem-stat-card.accent .stat-icon {
    background: rgba(227, 100, 20, 0.12);
    color: var(--vem-accent);
}

/* Page header */
.vem-page-header {
    margin-bottom: 1.5rem;
}

.vem-page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--vem-primary-dark);
    margin: 0;
}

.vem-page-header .subtitle {
    color: var(--vem-text-muted);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Tables */
.vem-table-wrap {
    overflow-x: auto;
}

.table.vem-table {
    margin-bottom: 0;
}

.table.vem-table thead th {
    background: var(--vem-bg);
    color: var(--vem-text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom-width: 1px;
    white-space: nowrap;
}

.table.vem-table tbody td {
    vertical-align: middle;
    font-size: 0.875rem;
}

/* Empty state */
.vem-empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--vem-text-muted);
}

.vem-empty-state .bi {
    font-size: 2.5rem;
    color: var(--vem-border);
    margin-bottom: 1rem;
}

/* Guest / login */
.vem-guest-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--vem-primary-dark) 0%, var(--vem-primary) 50%, #1a6b7d 100%);
    padding: 1.5rem;
}

.vem-guest-card {
    width: 100%;
    max-width: 420px;
    background: var(--vem-surface);
    border-radius: 12px;
    box-shadow: var(--vem-shadow-lg);
    overflow: hidden;
}

.vem-guest-card-header {
    background: var(--vem-primary-dark);
    color: #fff;
    padding: 2rem 2rem 1.5rem;
    text-align: center;
}

.vem-guest-card-header .brand-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: var(--vem-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.vem-guest-card-body {
    padding: 2rem;
}

/* Print layout */
@media print {
    .vem-sidebar,
    .vem-topbar,
    .vem-footer,
    .vem-sidebar-backdrop,
    .no-print {
        display: none !important;
    }

    .vem-main {
        margin: 0 !important;
        padding: 0 !important;
    }

    .vem-content {
        padding: 0 !important;
    }

    body {
        background: #fff !important;
    }
}

/* FullCalendar fallback styles (when CDN CSS unavailable) */
.fc {
    --fc-border-color: var(--vem-border);
    --fc-button-bg-color: var(--vem-primary);
    --fc-button-border-color: var(--vem-primary);
    --fc-button-hover-bg-color: var(--vem-primary-dark);
    --fc-button-hover-border-color: var(--vem-primary-dark);
    --fc-button-active-bg-color: var(--vem-primary-dark);
    --fc-button-active-border-color: var(--vem-primary-dark);
    --fc-today-bg-color: rgba(15, 76, 92, 0.06);
    --fc-event-bg-color: var(--vem-primary);
    --fc-event-border-color: var(--vem-primary);
    font-size: 0.875rem;
}

.fc .fc-toolbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--vem-primary-dark);
}

.fc .fc-col-header-cell-cushion,
.fc .fc-daygrid-day-number {
    color: var(--vem-text);
    text-decoration: none;
}

.fc-theme-standard td,
.fc-theme-standard th {
    border-color: var(--vem-border);
}

.fc .fc-button {
    border-radius: 6px;
    font-size: 0.8125rem;
    padding: 0.35rem 0.75rem;
}

.fc .fc-daygrid-day.fc-day-today {
    background: rgba(15, 76, 92, 0.06);
}

/* Status badges */
.badge-status-draft { background: #e9ecef; color: #495057; }
.badge-status-provisional { background: #fff3cd; color: #856404; }
.badge-status-confirmed { background: #d1e7dd; color: #0f5132; }
.badge-status-cancelled { background: #f8d7da; color: #842029; }
.badge-status-issued { background: #cfe2ff; color: #084298; }
.badge-status-due { background: #ffe5d0; color: #984c0c; }
.badge-status-paid { background: #d1e7dd; color: #0f5132; }
.badge-status-overdue { background: #f8d7da; color: #842029; }
.badge-status-active { background: #d1e7dd; color: #0f5132; }
.badge-status-inactive { background: #e9ecef; color: #6c757d; }

/* Form helpers */
.form-label.required::after {
    content: " *";
    color: var(--vem-accent);
}

.form-text-muted {
    font-size: 0.8125rem;
    color: var(--vem-text-muted);
}

/* Breadcrumbs */
.vem-breadcrumb {
    font-size: 0.8125rem;
    margin-bottom: 0.75rem;
}

.vem-breadcrumb .breadcrumb-item a {
    color: var(--vem-text-muted);
}

.vem-breadcrumb .breadcrumb-item.active {
    color: var(--vem-text);
}

/* Filter bar */
.vem-filter-bar {
    background: var(--vem-surface);
    border: 1px solid var(--vem-border);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

/* Utility */
[x-cloak] {
    display: none !important;
}

/* Attachments panel */
.attachments-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 1.25rem 1rem;
    border: 1.5px dashed var(--vem-border);
    border-radius: 10px;
    background: color-mix(in srgb, var(--vem-surface) 88%, var(--vem-primary, #0d6efd) 6%);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
    text-align: center;
}

.attachments-dropzone:hover {
    border-color: var(--vem-primary, #0d6efd);
    background: color-mix(in srgb, var(--vem-surface) 80%, var(--vem-primary, #0d6efd) 12%);
}

.attachments-dropzone-icon {
    font-size: 1.75rem;
    color: var(--vem-primary, #0d6efd);
    line-height: 1;
}

.attachments-dropzone-title {
    font-weight: 600;
    font-size: 0.9375rem;
}

.attachments-dropzone-meta {
    font-size: 0.75rem;
    color: var(--vem-text-muted);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 0.5rem;
}

.attachments-empty-icon {
    font-size: 1.75rem;
    color: var(--vem-text-muted);
    opacity: 0.55;
    display: block;
    margin-bottom: 0.35rem;
}

.attachments-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.attachments-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--vem-border);
    border-radius: 8px;
    background: var(--vem-surface);
}

.attachments-item-icon {
    font-size: 1.35rem;
    line-height: 1;
    flex-shrink: 0;
}

.attachments-item-actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
    margin-left: auto;
}

.invoice-payment-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.invoice-payment-summary .stat {
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--vem-border);
    background: color-mix(in srgb, var(--vem-surface) 92%, #000 3%);
}

.invoice-payment-summary .stat-label {
    font-size: 0.75rem;
    color: var(--vem-text-muted);
    margin-bottom: 0.15rem;
}

.invoice-payment-summary .stat-value {
    font-weight: 600;
    font-size: 0.95rem;
}

.payment-history-item {
    border: 1px solid var(--vem-border);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

.payment-history-item:last-child {
    margin-bottom: 0;
}
