/* PEVOTE Ticketing System v4.0 - Modern Design */

/* ============================================
   CSS CUSTOM PROPERTIES (Light & Dark themes)
   ============================================ */
:root {
    --eu-blue: #003399;
    --eu-blue-light: #0055cc;
    --eu-gold: #FFCC00;
    --sidebar-width: 250px;
    --sidebar-collapsed: 64px;
    --header-height: 56px;
    --bg-body: #f0f2f5;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f8f9fa;
    --bg-sidebar: #1e293b;
    --bg-sidebar-hover: #334155;
    --bg-sidebar-active: #0f172a;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-sidebar: #cbd5e1;
    --text-sidebar-active: #ffffff;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --transition: 0.2s ease;
}

[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-hover: #334155;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --bg-sidebar-active: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);
}

/* ============================================
   GLOBAL RESETS
   ============================================ */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    overflow-x: hidden;
}

[data-theme="dark"] .bg-white,
[data-theme="dark"] .card,
[data-theme="dark"] .card-header,
[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] .modal-content {
    background-color: var(--bg-surface) !important;
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: var(--bg-sidebar-hover);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .table {
    color: var(--text-primary);
}

[data-theme="dark"] .table > :not(caption) > * > * {
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .text-muted {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .dropdown-item {
    color: var(--text-primary);
}

[data-theme="dark"] .dropdown-item:hover {
    background-color: var(--bg-surface-hover);
}

[data-theme="dark"] .border-bottom {
    border-color: var(--border-color) !important;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    background: linear-gradient(135deg, #003399 0%, #001a66 100%);
}

.login-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    padding: 3rem;
}

.login-left h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.login-left p {
    font-size: 1.1rem;
    opacity: 0.85;
    max-width: 400px;
    text-align: center;
}

.login-right {
    width: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
}

.login-card {
    width: 100%;
    max-width: 400px;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.login-card .form-control {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
}

.login-card .btn-primary {
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
}

@media (max-width: 768px) {
    .login-left { display: none; }
    .login-right { width: 100%; }
    .login-page { background: #fff; }
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    z-index: 1040;
    transition: width var(--transition);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.sidebar-brand .brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-decoration: none;
}

.sidebar.collapsed .brand-text { display: none; }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .nav-section-title { display: none; }
.sidebar.collapsed .sidebar-footer-text { display: none; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 0;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.nav-section-title {
    padding: 16px 20px 6px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    white-space: nowrap;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 9px 20px;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.15s;
    white-space: nowrap;
    gap: 12px;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
}

.sidebar-link.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    border-left-color: var(--eu-blue-light);
}

.sidebar-link i {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 12px 0;
    border-left: none;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

/* ============================================
   TOP HEADER BAR
   ============================================ */
.top-header {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--header-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 1030;
    transition: left var(--transition);
    box-shadow: var(--shadow-sm);
}

body.sidebar-collapsed .top-header {
    left: var(--sidebar-collapsed);
}

.header-search {
    position: relative;
    width: 320px;
}

.header-search .form-control {
    padding-left: 36px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.875rem;
    height: 36px;
}

.header-search .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.header-search kbd {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1px 6px;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.header-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}

.header-btn:hover {
    background: var(--bg-body);
    color: var(--text-primary);
}

.header-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid var(--bg-surface);
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 24px;
    min-height: calc(100vh - var(--header-height));
    background: var(--bg-body);
    transition: margin-left var(--transition);
}

body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed);
}

body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed);
}

/* Plenary offset */
.plenary-banner {
    position: fixed;
    top: var(--header-height);
    left: var(--sidebar-width);
    right: 0;
    z-index: 1025;
    transition: left var(--transition);
}

body.sidebar-collapsed .plenary-banner {
    left: var(--sidebar-collapsed);
}

.main-content.plenary-offset {
    padding-top: 72px;
}

/* ============================================
   CARDS (Modern)
   ============================================ */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--bg-surface);
    transition: box-shadow 0.15s;
}

.card-header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 14px 20px;
    color: var(--text-primary);
}

.card-body {
    padding: 20px;
}

/* Stat Cards */
.stat-card {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    transition: transform 0.15s, box-shadow 0.15s;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.dashboard-link {
    cursor: pointer;
}

.dashboard-row {
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s;
}

.dashboard-row:hover {
    background-color: var(--bg-hover, rgba(0,0,0,0.04));
}

[data-theme="dark"] .dashboard-row:hover {
    background-color: rgba(255,255,255,0.06);
}

/* ============================================
   TABLES
   ============================================ */
.table {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.table thead th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    padding: 12px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 10px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

.table-hover tbody tr:hover {
    background-color: var(--bg-surface-hover);
}

.cursor-pointer {
    cursor: pointer;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    font-weight: 500;
    font-size: 0.72rem;
    padding: 0.35em 0.7em;
    border-radius: 5px;
    letter-spacing: 0.3px;
}

/* ============================================
   USER AVATAR
   ============================================ */
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.user-avatar-sm { width: 26px; height: 26px; font-size: 0.65rem; }
.user-avatar-lg { width: 40px; height: 40px; font-size: 0.9rem; }

/* ============================================
   FORMS
   ============================================ */
.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-size: 0.875rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--eu-blue);
    box-shadow: 0 0 0 3px rgba(0, 51, 153, 0.12);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--eu-blue);
    border-color: var(--eu-blue);
}

.btn-primary:hover {
    background: var(--eu-blue-light);
    border-color: var(--eu-blue-light);
}

/* ============================================
   SEARCH RESULTS DROPDOWN
   ============================================ */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1050;
    display: none;
}

.search-results.show { display: block; }

.search-result-item {
    display: block;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    transition: background 0.1s;
}

.search-result-item:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.search-result-item:last-child { border-bottom: none; }

/* ============================================
   TOAST CONTAINER
   ============================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1090;
}

/* ============================================
   FAVORITE / PIN BUTTON
   ============================================ */
.pin-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 1rem;
    transition: color 0.15s;
}

.pin-btn:hover,
.pin-btn.active {
    color: #f59e0b;
}

/* ============================================
   DRAG & DROP ZONE
   ============================================ */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
    transition: all 0.2s;
    cursor: pointer;
}

.drop-zone.drag-over {
    border-color: var(--eu-blue);
    background: rgba(0, 51, 153, 0.04);
    color: var(--eu-blue);
}

/* ============================================
   TIME TRACKER WIDGET
   ============================================ */
.timer-widget {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-body);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.timer-widget.running {
    background: #dcfce7;
    color: #166534;
}

[data-theme="dark"] .timer-widget.running {
    background: #14532d;
    color: #bbf7d0;
}

.timer-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ============================================
   KEYBOARD SHORTCUT MODAL
   ============================================ */
.shortcut-key {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.8rem;
    min-width: 28px;
    text-align: center;
}

/* ============================================
   BATCH ACTION BAR
   ============================================ */
.batch-bar {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--eu-blue);
    color: #fff;
    padding: 10px 20px;
    display: none;
    align-items: center;
    gap: 16px;
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
    z-index: 100;
}

.batch-bar.show { display: flex; }

/* ============================================
   WHITESPACE & UTILITY
   ============================================ */
.whitespace-pre-wrap {
    white-space: pre-wrap;
    word-break: break-word;
}

.priority-critical { color: #dc3545; }
.priority-high { color: #fd7e14; }
.priority-medium { color: #0d6efd; }
.priority-low { color: #6c757d; }

/* ============================================
   MOBILE SIDEBAR TOGGLE
   ============================================ */
.sidebar-toggle-mobile {
    display: none;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1035;
    }

    .sidebar-overlay.show { display: block; }

    .top-header {
        left: 0 !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .plenary-banner {
        left: 0 !important;
    }

    .sidebar-toggle-mobile {
        display: flex;
    }

    .header-search {
        width: 200px;
    }
}

@media (max-width: 576px) {
    .main-content {
        padding: 16px;
    }

    .header-search {
        display: none;
    }

    .stat-card .stat-value {
        font-size: 1.25rem;
    }
}

/* ============================================
   MORNING CHECK
   ============================================ */
.morning-check-room-card {
    min-height: 120px;
    transition: transform var(--transition), box-shadow var(--transition);
}
.morning-check-room-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.qr-item {
    page-break-inside: avoid;
    break-inside: avoid;
}

/* ============================================
   INVENTORY
   ============================================ */

/* Scan page - large touch-friendly input */
.inv-scan-input-wrap {
    position: relative;
}

.inv-scan-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.25rem;
    color: var(--text-muted);
    pointer-events: none;
}

.inv-scan-input {
    padding-left: 48px !important;
    font-size: 1.25rem !important;
    height: 56px;
}

/* Scan result cards */
.inv-scan-result {
    transition: transform var(--transition), box-shadow var(--transition);
}
.inv-scan-result:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Inventory autocomplete dropdown */
.inv-autocomplete-wrap {
    position: relative;
}
.inv-autocomplete-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    max-height: 280px;
    overflow-y: auto;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: var(--shadow-md);
}
.inv-ac-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--bs-border-color, #f0f0f0);
    transition: background var(--transition);
}
.inv-ac-item:last-child {
    border-bottom: none;
}
.inv-ac-item:hover,
.inv-ac-item.active {
    background: var(--bs-tertiary-bg, #f8f9fa);
}
[data-bs-theme="dark"] .inv-autocomplete-dropdown {
    background: var(--bs-body-bg, #212529);
    border-color: var(--bs-border-color, #495057);
}
[data-bs-theme="dark"] .inv-ac-item:hover,
[data-bs-theme="dark"] .inv-ac-item.active {
    background: var(--bs-tertiary-bg, #2b3035);
}

/* Dashboard clickable stats/rows */
.dashboard-link {
    transition: transform var(--transition), box-shadow var(--transition);
}
.dashboard-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.dashboard-row {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.dashboard-row:hover {
    background: var(--bg-surface-hover);
}

[data-theme="dark"] .dashboard-link:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

[data-theme="dark"] .dashboard-row:hover {
    background: var(--bg-surface-hover);
}

/* ============================================
   PRINT
   ============================================ */
@media print {
    .sidebar, .top-header, .batch-bar, .toast-container,
    .sidebar-overlay, .plenary-banner, .no-print {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd;
    }

    .qr-item .card {
        border: 1px solid #ccc;
    }

    /* Report print: force light backgrounds, readable charts */
    .chart-container {
        height: 250px !important;
        break-inside: avoid;
    }

    .chart-container canvas {
        max-width: 100% !important;
    }

    .row.g-4 > [class*="col-"] {
        break-inside: avoid;
    }
}

/* Report Charts */
.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}

/* ============================================
   CATEGORY DRAG & DROP REORDER
   ============================================ */
.drag-handle {
    display: none;
    cursor: grab;
    color: var(--text-muted);
    padding: 0 4px;
    font-size: 1.1rem;
}

.drag-handle:active {
    cursor: grabbing;
}

.reorder-mode .drag-handle {
    display: inline-flex;
    align-items: center;
}

.reorder-mode .cat-row[draggable="true"] {
    cursor: default;
    transition: opacity 0.15s, background-color 0.15s;
}

.reorder-mode .cat-row[draggable="true"]:hover {
    background-color: rgba(0, 51, 153, 0.04);
}

.cat-block.dragging {
    opacity: 0.4;
}

.cat-row.drag-over-above {
    box-shadow: 0 -4px 0 0 #000 !important;
}

.cat-row.drag-over-below {
    box-shadow: 0 4px 0 0 #000 !important;
}

.reorder-mode .cat-actions,
.reorder-mode .wiki-actions,
.reorder-mode .inv-actions {
    display: none !important;
}

.wiki-folder-row.dragging,
.inv-cat-row.dragging {
    opacity: 0.4;
}
