/* --- THEME, AURORA, & GLASSMORPHISM --- */
:root {
    --ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-in-out-cubic: cubic-bezier(0.65, 0, 0.35, 1);
    
    --accent-primary: #0277fa; /* New Blue - Default */
    --accent-primary-hover: #0157b1;
    --accent-primary-light: rgba(2, 119, 250, 0.1);
    --accent-gradient: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
    
    --monthly-revenue-color: #fbbb5d;
    --yearly-revenue-color: #1ec1aa;
    --bookings-color: #e24438;

    --ui-border-radius: 16px;  
}

[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --border-primary: #e2e8f0;
    --status-editing: #f59e0b;
    --status-editing-bg: rgba(245, 158, 11, 0.1);
    --status-delivered: #10b981;
    --status-delivered-bg: rgba(16, 185, 129, 0.1);
    --status-cancelled: #ef4444;
    --status-cancelled-bg: rgba(239, 68, 68, 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.05), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    --unpaid-color: #f59e0b;
}

[data-theme="dark"] {
    --bg-primary: #0a0a0a;
    --bg-secondary: #1b1b1b;
    --bg-tertiary: #2a2a2a;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-tertiary: #6b7280;
    --border-primary: #3a3a3a;
    --status-editing: #fcd34d;
    --status-editing-bg: rgba(252, 211, 77, 0.1);
    --status-delivered: #34d399;
    --status-delivered-bg: rgba(52, 211, 153, 0.1);
    --status-cancelled: #f87171;
    --status-cancelled-bg: rgba(248, 113, 113, 0.1);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.4), 0 8px 10px -6px rgb(0 0 0 / 0.4);
    --unpaid-color: #f59e0b;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: var(--bg-primary);
    z-index: -1;
}

/* --- GLOBAL STYLES --- */
html { scroll-behavior: smooth; }
body {
    font-family: 'Lexend', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-primary);
    margin: 0;
    overflow: hidden;
    opacity: 0; /* Hide body initially to prevent flash of login screen */
    transition: opacity 0.3s ease-in-out;
}
* { box-sizing: border-box; }

.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--ui-border-radius);
    padding: 24px;
}

/* --- LOGIN SCREEN STYLES --- */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    width: 100vw;
    transition: opacity 0.3s ease-in-out;
}
#login-form-container {
    width: 100%;
    max-width: 400px;
    padding: 24px;
}
#login-form-container h2 {
    text-align: center;
    margin-bottom: 24px;
}

/* --- SCROLLBAR THEME --- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background-color: var(--border-primary); border-radius: 10px; border: 2px solid transparent; background-clip: content-box;}
::-webkit-scrollbar-thumb:hover { background-color: var(--text-tertiary); }


/* --- APP LAYOUT --- */
#app-container {
    display: grid;
    grid-template-columns: 80px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "nav header"
        "nav main";
    height: 100vh;
    transition: opacity 0.3s ease-in-out, grid-template-columns 0.3s var(--ease-in-out-cubic);
}

/* --- NAVIGATION SIDEBAR --- */
#main-nav {
    grid-area: nav;
    background-color: transparent;
    padding: 24px 16px;
    display: flex; 
    flex-direction: column;
    align-items: center;
}
.nav-header {
    margin-bottom: 48px;
}
.nav-logo-img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}
.logo-light { display: none; }
.logo-dark { display: block; }

[data-theme="light"] .logo-light { display: block; }
[data-theme="light"] .logo-dark { display: none; }

.nav-list {
    list-style: none; padding: 0; margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    flex-grow: 1;
    justify-content: center;
}
.nav-footer { 
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.nav-item a {
    display: flex; align-items: center; justify-content: center;
    width: 48px; height: 48px;
    border-radius: 12px;
    color: var(--text-tertiary);
    text-decoration: none;
    transition: all 0.2s;
    position: relative;
}
.nav-item a:hover { 
    background-color: var(--accent-primary-light); 
    color: var(--accent-primary); 
    transform: translateY(-2px);
}
.nav-item a.active { 
    background: var(--accent-gradient);
    color: white; 
    box-shadow: 0 4px 12px rgba(2, 119, 250, 0.3);
}
.nav-item a.active:hover { color: white; transform: translateY(0); }
.nav-item a.active svg { color: white !important; }
.nav-item svg { width: 24px; height: 24px; }
.nav-item .tooltip {
    position: absolute;
    left: 120%;
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    border: 1px solid var(--border-primary);
    z-index: 10;
}
.nav-item a:hover .tooltip {
    opacity: 1;
    visibility: visible;
}

/* --- HEADER --- */
#main-header {
    grid-area: header;
    background-color: transparent;
    padding: 16px 32px;
    display: flex; justify-content: space-between; align-items: center;
}
#view-title {
    font-size: 24px;
    font-weight: 600;
}
#quick-stats {
    display: flex;
    gap: 24px;
    align-items: center;
    font-size: 14px;
}
.quick-stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}
.quick-stat-item .lucide {
    width: 16px;
    height: 16px;
}
.quick-stat-item strong {
    color: var(--text-primary);
    font-weight: 600;
}

#save-status {
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s;
}
#save-status.synced {
    color: var(--status-delivered);
    background-color: var(--status-delivered-bg);
}
#save-status.syncing {
    color: var(--status-editing);
    background-color: var(--status-editing-bg);
}
#save-status.offline {
    color: var(--status-cancelled);
    background-color: var(--status-cancelled-bg);
}
#save-status .lucide-spin { animation: spin 1.5s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }


/* --- MAIN CONTENT --- */
#main-content {
    grid-area: main;
    overflow: hidden;
    padding: 0 32px 32px 32px;
}
.view { 
    height: 100%; 
    overflow-y: auto; 
    overflow-x: hidden;
    display: none;
}
.view.active { 
    display: block;
    animation: fadeInSlideUp 0.5s var(--ease-out-quad); 
}
@keyframes fadeInSlideUp { 
    from { opacity: 0; transform: translateY(15px); } 
    to { opacity: 1; transform: translateY(0); } 
}


/* --- DASHBOARD VIEW --- */
#dashboard-view-grid {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 24px;
    height: 100%;
}
#dashboard-main-panel {
    background-color: var(--bg-secondary);
    border-radius: var(--ui-border-radius);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100%;
    overflow: hidden;
}
#dashboard-entries { 
    display: flex; flex-direction: column;
    padding: 16px;
    overflow: hidden;
    background-color: var(--bg-secondary);
    border-radius: var(--ui-border-radius);
}
#entries-header { margin: 0 0 16px; }
#entries-header h3 { margin: 0 0 12px 0; font-size: 18px; font-weight: 600; }
.search-wrapper { position: relative; }
.search-wrapper .lucide-search { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); width: 18px; height: 18px;}
#booking-search, #entries-search { 
    padding-left: 40px; 
}
#dashboard-entries-list {
    flex-grow: 1;
    overflow-y: auto;
    display: flex; flex-direction: column; gap: 12px;
    padding: 4px;
}


.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.kpi-card { 
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--ui-border-radius);
    padding: 24px;
    display: flex; 
    flex-direction: column;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s var(--ease-out-quad), box-shadow 0.3s var(--ease-out-quad);
}
.kpi-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 25px 30px -10px rgb(0 0 0 / 0.4);
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--aurora-bg);
    background-size: 300% 300%;
    animation: aurora-card 15s infinite linear;
    opacity: 0.7;
}
@keyframes aurora-card {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.kpi-card.monthly-revenue-glow { --aurora-bg: radial-gradient(at 80% 20%, hsla(43, 96%, 68%, 0.25) 0px, transparent 50%), radial-gradient(at 20% 90%, hsla(38, 96%, 68%, 0.2) 0px, transparent 50%); }
.kpi-card.yearly-revenue-glow { --aurora-bg: radial-gradient(at 80% 20%, hsla(170, 72%, 52%, 0.25) 0px, transparent 50%), radial-gradient(at 20% 90%, hsla(170, 72%, 42%, 0.2) 0px, transparent 50%); }
.kpi-card.bookings-glow { --aurora-bg: radial-gradient(at 80% 20%, hsla(4, 76%, 61%, 0.25) 0px, transparent 50%), radial-gradient(at 20% 90%, hsla(4, 76%, 51%, 0.2) 0px, transparent 50%); }

.kpi-card-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.kpi-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px;}
.kpi-card-title { font-size: 14px; color: var(--text-secondary); }
.kpi-card-icon { color: var(--text-tertiary); }
.kpi-card-value { font-size: 28px; font-weight: 700; margin-top: auto; }
.kpi-card-value.monthly-revenue { color: var(--monthly-revenue-color); }
.kpi-card-value.yearly-revenue { color: var(--yearly-revenue-color); }
.kpi-card-value.bookings { color: var(--bookings-color); }

/* --- DASHBOARD ENTRY CARD --- */
.dashboard-entry-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    padding: 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.dashboard-entry-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-primary);
    box-shadow: 0 8px 15px -3px rgba(0,0,0,0.2);
}
.entry-card-main {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.entry-card-header { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.entry-card-header .lucide { width: 18px; height: 18px; color: var(--text-secondary); flex-shrink: 0; }
.entry-card-details { font-size: 13px; color: var(--text-tertiary); display: flex; align-items: center; gap: 8px; }
.entry-card-price { font-weight: 600; font-size: 14px; color: var(--accent-primary); }
.entry-card-status { flex-shrink: 0; margin-left: 16px; }


/* --- REVENUE CHART --- */
#dashboard-chart {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}
#revenueChartContainer { 
    position: relative; 
    flex-grow: 1;
}
.chart-empty-state, .empty-state-container {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    color: var(--text-tertiary); text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.empty-state-container .lucide { width: 48px; height: 48px; }
.empty-state-container p { margin: 0; max-width: 300px; }


/* --- BOTTOM STATS --- */
#bottom-stats-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--border-primary);
    padding-top: 24px;
}
.icon-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}
.icon-stat .stat-icon {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.icon-stat .stat-icon .lucide { width: 20px; height: 20px; }
.icon-stat .value { font-size: 20px; font-weight: 600; }
.stats-separator {
    width: 1px;
    height: 30px;
    background-color: var(--border-primary);
}
.icon-stat .tooltip {
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    border: 1px solid var(--border-primary);
    z-index: 10;
}
.icon-stat:hover .tooltip {
    opacity: 1;
    visibility: visible;
}


/* --- BOOKING FORM MODAL (REDESIGNED) --- */
#booking-form-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 100;
    display: flex; 
    align-items: center; 
    justify-content: center;
    padding: 16px;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}
#booking-form-modal.visible {
    opacity: 1; visibility: visible;
}
#booking-form-modal .modal-content {
    background-color: var(--bg-secondary);
    border-radius: var(--ui-border-radius);
    width: 100%;
    max-width: 550px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 40px);
    transform: scale(0.95);
    transition: transform 0.3s var(--ease-out-quad);
}
#booking-form-modal.visible .modal-content {
    transform: scale(1);
}
.modal-header {
    padding: 20px 24px; border-bottom: 1px solid var(--border-primary);
    display: flex; justify-content: space-between; align-items: center;
    flex-shrink: 0;
}
.modal-header h3 { margin: 0; font-size: 18px; font-weight: 600; }
.modal-body { 
    padding: 24px; 
    overflow-y: auto; 
    flex-grow: 1; 
}
.modal-footer {
    padding: 16px 24px; border-top: 1px solid var(--border-primary);
    display: flex; justify-content: space-between; align-items: center;
    flex-shrink: 0;
    background-color: var(--bg-tertiary);
    border-bottom-left-radius: var(--ui-border-radius);
    border-bottom-right-radius: var(--ui-border-radius);
}

.entry-type-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.entry-type-group label {
    padding: 12px; border: 1px solid var(--border-primary); border-radius: 8px;
    font-weight: 500; gap: 8px; display: flex; flex-direction: column; align-items: center;
    justify-content: center; cursor: pointer; transition: all 0.2s;
    margin: 0; font-size: 12px; height: 80px;
}
.entry-type-group .lucide { width: 24px; height: 24px; }
.entry-type-group input[type="radio"] { display: none; }
.entry-type-group input[type="radio"]:checked + label {
    background-color: var(--accent-primary-light);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* Redesigned Payment Toggle */
.payment-toggle {
    display: flex;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    overflow: hidden;
}
.payment-toggle button {
    flex: 1;
    background-color: transparent;
    border: none;
    padding: 10px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    color: var(--text-secondary);
}
.payment-toggle button.active {
    font-weight: 600;
}
.payment-toggle button[data-paid="false"].active {
    background-color: var(--status-editing-bg);
    color: var(--status-editing);
}
.payment-toggle button[data-paid="true"].active {
    background-color: var(--status-delivered-bg);
    color: var(--status-delivered);
}


/* --- CUSTOM DROPDOWN --- */
.custom-dropdown {
    position: relative;
    width: 100%;
    font-family: 'Lexend', sans-serif;
}
.custom-dropdown-selected {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-primary);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.custom-dropdown-selected:hover, .custom-dropdown.open .custom-dropdown-selected {
     border-color: var(--accent-primary);
     box-shadow: 0 0 0 3px var(--accent-primary-light);
}
.custom-dropdown-options {
    position: absolute;
    top: 105%;
    left: 0;
    right: 0;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    z-index: 1001;
    max-height: 220px; /* Increased max-height slightly */
    overflow-y: auto;
    display: none;
    box-shadow: var(--shadow-lg);
}
/* New rule to open dropdown upwards */
.custom-dropdown-options.open-up {
    top: auto;
    bottom: 105%;
}
.custom-dropdown.open .custom-dropdown-options {
    display: block;
}
.custom-dropdown-option {
    padding: 10px 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.custom-dropdown-option:hover {
    background-color: var(--accent-primary-light);
    color: var(--accent-primary);
}
.custom-dropdown-option.selected {
    background-color: var(--accent-primary);
    color: white;
}
.filter-dropdown .custom-dropdown-selected {
    height: 44px;
}


/* --- UTILITY & COMPONENT STYLES --- */
.btn {
    padding: 10px 16px; border-radius: 8px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid transparent; white-space: nowrap;
}
.btn:hover {
    transform: translateY(-2px);
}
.btn .lucide { width: 16px; height: 16px; }
.btn-primary { 
    background: var(--accent-gradient);
    color: white; 
    border: none;
    box-shadow: 0 2px 8px rgba(2, 119, 250, 0.3);
}
.btn-primary:hover { 
    opacity: 0.9;
    box-shadow: 0 4px 12px rgba(2, 119, 250, 0.4);
}
.btn-secondary { background-color: var(--bg-tertiary); color: var(--text-primary); border-color: var(--border-primary); }
.btn-secondary:hover { background-color: var(--border-primary); }
.btn-danger { background-color: transparent; color: var(--status-cancelled); border-color: var(--status-cancelled); }
.btn-danger:hover { background-color: var(--status-cancelled-bg); }
.btn-icon { padding: 10px; }

.form-group { margin-bottom: 20px; }
label { display: block; margin-bottom: 8px; font-weight: 500; font-size: 14px; color: var(--text-primary); }
input, textarea, select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border-primary); background-color: var(--bg-primary);
    color: var(--text-primary); border-radius: 8px; font-size: 14px;
    transition: all 0.2s; font-family: 'Lexend', sans-serif;
}
input:focus, textarea:focus, select:focus {
    outline: none; border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-light);
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }


/* --- TOAST & MODAL --- */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 1002; }
.toast {
    background-color: var(--bg-secondary); color: var(--text-primary); padding: 16px; border-radius: 8px;
    border: 1px solid var(--border-primary); margin-bottom: 12px; opacity: 0;
    transform: translateX(100%); animation: slideInRight 0.5s var(--ease-out-quad) forwards, slideOutRight 0.5s var(--ease-out-quad) 3.5s forwards;
    display: flex; align-items: center; gap: 12px; min-width: 320px;
}
.toast .lucide { width: 20px; height: 20px; }
.toast.success .lucide { color: var(--status-delivered); }
.toast.error .lucide { color: var(--status-cancelled); }
@keyframes slideInRight { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOutRight { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(100%); } }

/* --- STATUS & TABLE STYLES --- */
.status-pill {
    padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
    text-transform: capitalize; display: inline-flex; align-items: center; gap: 6px;
}
.paid-status { color: var(--status-delivered); background-color: var(--status-delivered-bg); }
.unpaid-status { color: var(--unpaid-color); background-color: rgba(245, 158, 11, 0.1); }
.table-container { overflow-x: auto; position: relative; }
.entries-table { width: 100%; border-collapse: collapse; }
.entries-table th, .entries-table td {
    padding: 12px 16px; text-align: left;
    border-bottom: 1px solid var(--border-primary); font-size: 14px;
}
.entries-table th { color: var(--text-secondary); font-weight: 500; text-transform: uppercase; font-size: 12px; cursor: pointer; user-select: none; }
.entries-table th:hover { color: var(--text-primary); }
.entries-table tbody tr { transition: background-color 0.2s; animation: tableRowFadeIn 0.5s var(--ease-out-quad); }
@keyframes tableRowFadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.entries-table tbody tr:hover { 
    background-color: var(--accent-primary-light); 
}
.entries-table .lucide { width: 18px; height: 18px; color: var(--text-secondary); }
.entries-table tbody tr:nth-child(even) { background-color: rgba(128,128,128,0.02); }


/* --- AGENT & STATUS MANAGEMENT --- */
#agents-view-grid {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 24px;
    height: 100%;
}
#agentList {
    list-style: none; padding: 0; margin: 0; 
    display: flex; flex-direction: column; gap: 8px; 
    overflow-y: auto; 
    flex-grow: 1;
    height: 0;
}
.management-list-item { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 12px; 
    border-radius: 8px; 
    transition: background-color 0.2s;
    cursor: pointer;
}
.management-list-item:hover, .management-list-item.active { 
    background-color: var(--accent-primary-light); 
}
.agent-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.agent-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--text-secondary);
    overflow: hidden;
    flex-shrink: 0;
}
.agent-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.agent-details { display: flex; flex-direction: column; gap: 4px; }
.agent-name { font-weight: 500; }
.agent-stats { font-size: 12px; color: var(--text-tertiary); }
.agent-actions { display: flex; gap: 8px; }
#agent-detail-panel .card { height: 100%; }
.status-usage-count {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary);
    background-color: var(--bg-primary);
    padding: 2px 8px;
    border-radius: 6px;
    margin-left: auto;
    margin-right: 12px;
}

/* --- SETTINGS PAGE STYLES --- */
#settings-view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    position: relative;
    padding-bottom: 30px; /* Space for version number */
}
#app-version {
    position: absolute;
    bottom: 0;
    right: 0;
    font-size: 12px;
    color: var(--text-tertiary);
}
.setting-group {
    display: flex;
    align-items: center;
    gap: 12px;
}
.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color 0.2s;
}
.color-swatch.active {
    border-color: var(--text-primary);
}
.logo-upload-group {
    display: flex;
    align-items: center;
    gap: 16px;
}
.logo-preview {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.logo-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}


/* --- COMMAND PALETTE --- */
#command-palette {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1001;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}
#command-palette-content {
    width: 90%;
    max-width: 600px;
    background-color: var(--bg-secondary);
    border-radius: var(--ui-border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}
#command-palette-search {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    border: none;
    border-bottom: 1px solid var(--border-primary);
}
#command-palette-results {
    max-height: 40vh;
    overflow-y: auto;
}
.command-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.command-item:hover, .command-item.active {
    background-color: var(--accent-primary-light);
    color: var(--accent-primary);
}
.command-item .lucide { color: var(--text-tertiary); }
.command-item:hover .lucide, .command-item.active .lucide { color: var(--accent-primary); }


/* --- CONTEXT MENU --- */
#context-menu {
    position: fixed;
    z-index: 10000;
    width: 200px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 8px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.15s, transform 0.15s;
    pointer-events: none;
}
#context-menu.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}
.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}
.context-menu-item:hover {
    background-color: var(--accent-primary-light);
    color: var(--accent-primary);
}
.context-menu-item .lucide { width: 16px; height: 16px; }


/* --- BULK ACTION BAR (REDESIGNED) --- */
#bulk-action-bar {
    position: absolute;
    bottom: 24px;
    left: 50%;
    background-color: var(--bg-secondary);
    padding: 8px;
    border-radius: 12px;
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 50;
    opacity: 0;
    transform: translate(-50%, 20px) scale(0.95);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}
#bulk-action-bar.visible {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
    pointer-events: auto;
}
#bulk-action-bar .btn {
    background-color: var(--bg-tertiary);
    border-color: var(--border-primary);
}
#bulk-action-bar .btn:hover {
    background-color: var(--border-primary);
    transform: translateY(-1px);
}
#bulk-action-bar .btn-danger {
    background-color: var(--status-cancelled-bg);
    border-color: var(--status-cancelled-bg);
    color: var(--status-cancelled);
}
#bulk-action-bar .btn-danger:hover {
    background-color: var(--status-cancelled);
    color: white;
}


/* --- RESPONSIVE DESIGN --- */
#entries-mobile-stats, #entries-desktop-stats { display: none; }

@media (max-width: 768px) {
    #app-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        grid-template-areas:
            "header"
            "main"
            "nav";
        padding-bottom: 60px; /* Space for bottom nav */
    }
    #main-nav {
        flex-direction: row;
        justify-content: space-between;
        padding: 8px 16px;
        border-top: 1px solid var(--border-primary);
        background-color: var(--bg-secondary);
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        z-index: 100;
    }
    .nav-header { display: none; }
    .nav-footer { 
        display: flex;
        flex-direction: row;
        gap: 8px;
        width: auto;
        margin-top: 0;
    }
    .nav-list { 
        flex-direction: row; 
        gap: 8px;
        justify-content: flex-start;
        width: auto;
        flex-grow: 0;
    }
    .nav-item .tooltip { display: none; }
    
    .nav-item a.active {
        background: var(--accent-primary-light);
        color: var(--accent-primary);
        box-shadow: none;
    }
    .nav-item a.active svg {
        color: var(--accent-primary) !important;
    }
    
    #dashboard-view-grid, #agents-view-grid {
        grid-template-columns: 1fr;
    }
    
    #dashboard-view-grid {
        gap: 16px;
    }
    #dashboard-main-panel {
        padding: 0;
        background: transparent;
        border: none;
        border-radius: 0;
        display: block;
    }
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    #dashboard-chart, #bottom-stats-container, #dashboard-entries {
        display: none;
    }
    
    #main-header { padding: 16px; }
    #main-content { padding: 0 16px 16px 16px; }
    #view-title { font-size: 20px; }
    #quick-stats { display: none; }
    #booking-form-modal .modal-content {
        max-width: 100%;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    #agent-detail-panel {
        display: none;
    }

    .entries-table thead {
        display: none;
    }
    .entries-table, .entries-table tbody, .entries-table tr, .entries-table td {
        display: block;
        width: 100%;
    }
    .entries-table tr {
        background-color: var(--bg-tertiary);
        border: 1px solid var(--border-primary);
        border-radius: 12px;
        margin-bottom: 16px;
        padding: 16px;
    }
    .entries-table tr:nth-child(even) {
        background-color: var(--bg-tertiary);
    }
    .entries-table td {
        padding: 8px 0;
        border: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        border-bottom: 1px dashed var(--border-primary);
    }
    .entries-table tr td:last-child {
        border-bottom: none;
    }
    .entries-table td::before {
        content: attr(data-label);
        font-weight: 500;
        color: var(--text-secondary);
        text-align: left;
        margin-right: 16px;
    }
    .entries-table td:nth-of-type(1) { /* Checkbox */
        justify-content: flex-start;
        padding-bottom: 12px;
    }
    .entries-table td:nth-of-type(1)::before {
        display: none;
    }
    .entries-table td[data-label="Location / Agent"] > div {
        flex-grow: 1;
        justify-content: flex-end;
    }
    .entries-table td[data-label="Location / Agent"] .agent-avatar {
        display: none; /* Hide avatar in card view to save space */
    }
     .entries-table td[data-label="Location / Agent"] div div {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
    }
    
    /* CHANGE: Mobile Bookings View */
    #entries-view .card:first-child {
        display: none;
    }
}
