/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Primary Brand Colors */
    --orange: #ff6b2b;
    --orange-dark: #e85520;
    
    /* Light Theme (Default) */
    --bg: #ffffff;
    --surface: #f8f9fa;
    --card: #ffffff;
    --text: #1a1a1a;
    --text-muted: #666666;
    --glass: rgba(0, 0, 0, 0.02);
    --glass-border: rgba(0, 0, 0, 0.08);
    --radius-md: 16px;
    --transition: all 0.3s ease;
    
    --display-sun: none;
    --display-moon: block;
    --calendar-filter: none;
    --toggle-bg: var(--glass);
    --toggle-color: var(--text-muted);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #050505;
        --surface: #0f0f0f;
        --card: #151515;
        --text: #f8f8f8;
        --text-muted: #a0a0a0;
        --glass: rgba(255, 255, 255, 0.03);
        --glass-border: rgba(255, 255, 255, 0.08);
        --display-sun: block;
        --display-moon: none;
        --calendar-filter: invert(1);
        --toggle-bg: rgba(255, 255, 255, 0.05);
        --toggle-color: var(--text);
    }
}

[data-theme="dark"] {
    --bg: #050505;
    --surface: #0f0f0f;
    --card: #151515;
    --text: #f8f8f8;
    --text-muted: #a0a0a0;
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --display-sun: block;
    --display-moon: none;
    --calendar-filter: invert(1);
    --toggle-bg: rgba(255, 255, 255, 0.05);
    --toggle-color: var(--text);
}

/* Fix for browser-native date/time icons in dark mode */
input::-webkit-calendar-picker-indicator {
    filter: var(--calendar-filter);
}

.theme-transition,
.theme-transition *,
.theme-transition *::before,
.theme-transition *::after {
    transition: background 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
                color 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
                border-color 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
                box-shadow 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
                filter 0.6s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

body {
    background: var(--bg);
    font-family: 'Alexandria', system-ui, sans-serif;
    color: var(--text);
    min-height: 100vh;
    display: flex;
}

/* ===== SIDEBAR ===== */
.admin-sidebar {
    width: 250px;
    background: var(--surface);
    border-right: 1px solid var(--glass-border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
}

.admin-logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.admin-logo i { color: var(--orange); }

.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-nav a {
    text-decoration: none;
    color: var(--text-muted);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
}

.admin-nav a:hover, .admin-nav a.active {
    background: rgba(255, 107, 43, 0.1);
    color: var(--orange);
}

/* Theme Toggle */
.theme-toggle {
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-muted) !important;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    width: 100%;
    border-radius: 12px;
    margin: 0;
    background: var(--toggle-bg);
    border: 1px solid var(--glass-border);
    padding: 12px 16px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    position: relative;
    overflow: hidden;
}

.theme-toggle i {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.theme-toggle .fa-sun { display: var(--display-sun); color: #f1c40f; }
.theme-toggle .fa-moon { display: var(--display-moon); color: #34495e; }

.theme-toggle:hover {
    background: var(--surface) !important;
    color: var(--orange) !important;
    border-color: var(--orange) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .theme-toggle:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* ===== MAIN CONTENT ===== */
.admin-main {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
}

.admin-header {
    margin-bottom: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-header h1 {
    font-size: 28px;
    font-weight: 700;
}

/* ===== CARDS / STATS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 50px; height: 50px;
    border-radius: 12px;
    background: rgba(255, 107, 43, 0.1);
    color: var(--orange);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
}

.stat-info h3 { font-size: 14px; color: var(--text-muted); font-weight: 400; margin-bottom: 4px; }
.stat-info .stat-val { font-size: 24px; font-weight: 700; color: var(--text); }

/* ===== SECTIONS ===== */
.admin-section { display: none; }
.admin-section.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ===== TABLES ===== */
.admin-table-container {
    background: var(--card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.admin-table th {
    padding: 16px 24px;
    font-size: 13px;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--glass);
    border-bottom: 1px solid var(--glass-border);
}

.admin-table td {
    padding: 16px 24px;
    font-size: 14px;
    border-bottom: 1px solid var(--glass-border);
}

.admin-table tr:hover { background: var(--glass); }
.admin-table tr:last-child td { border-bottom: none; }

.action-btn {
    background: none; border: none; cursor: pointer; color: var(--text-muted);
    margin-right: 12px; transition: var(--transition); font-size: 14px;
}
.action-btn.edit:hover { color: #3498db; }
.action-btn.delete:hover { color: #e74c3c; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 8px; font-size: 13px; color: var(--text-muted); }
.form-control {
    width: 100%; padding: 12px 16px;
    background: var(--surface); border: 1px solid var(--glass-border);
    border-radius: 8px; color: var(--text); font-family: inherit; font-size: 14px;
}
.form-control:focus { outline: none; border-color: var(--orange); }

.btn {
    padding: 10px 20px; border: none; border-radius: 8px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: var(--transition); font-family: inherit;
}
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--glass-border); }
.btn-secondary:hover { background: var(--glass); }

/* Modal */
.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(5px);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
    opacity: 0; visibility: hidden; transition: var(--transition);
}
.modal.show { opacity: 1; visibility: visible; }
.modal-content {
    background: var(--card); border: 1px solid var(--glass-border);
    border-radius: var(--radius-md); padding: 32px; width: 100%; max-width: 500px;
    max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-title { font-size: 20px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; }
.modal-close:hover { color: var(--text); }

/* Custom File Upload */
.file-upload-wrapper {
    position: relative;
    width: 100%;
}

.file-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 16px;
    background: var(--surface);
    border: 2px dashed var(--glass-border);
    border-radius: 12px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.file-upload-btn:hover {
    border-color: var(--orange);
    color: var(--orange);
    background: rgba(255, 107, 43, 0.05);
    transform: translateY(-2px);
}

.file-upload-btn i {
    font-size: 18px;
}

/* Image Preview Box */
.preview-box {
    width: 100%;
    height: 180px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
}

.preview-placeholder i {
    font-size: 40px;
    opacity: 0.3;
}

.preview-placeholder p {
    font-size: 13px;
    font-weight: 500;
}

/* ===== FLOOR PLAN EDITOR ===== */
.floor-plan-wrapper {
    display: flex;
    gap: 20px;
    height: calc(100vh - 160px);
    min-height: 500px;
}

.floor-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.floor-sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--glass-border);
    font-weight: 700;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.floor-sidebar-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.floor-sidebar .form-group {
    margin-bottom: 0;
}

.floor-canvas {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    overflow: auto;
    position: relative;
    cursor: default;
}

.floor-room {
    position: relative;
    width: 1000px;
    height: 700px;
    background:
        repeating-linear-gradient(var(--glass-border) 0 1px, transparent 1px 40px),
        repeating-linear-gradient(90deg, var(--glass-border) 0 1px, transparent 1px 40px);
    background-color: var(--card);
    border-radius: 8px;
    margin: 20px;
    box-shadow: 0 0 0 2px var(--glass-border);
}

/* Table Element */
.floor-table {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    user-select: none;
    transition: box-shadow 0.2s ease, transform 0.15s ease, filter 0.2s ease;
    z-index: 10;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.35));
}

.floor-table:hover { filter: drop-shadow(0 6px 16px rgba(0,0,0,0.5)); transform: translateY(-1px); }
.floor-table:active { cursor: grabbing; transform: scale(1.06); }

.floor-table.selected {
    box-shadow: 0 0 0 3px var(--orange), 0 8px 28px rgba(255,107,43,0.5) !important;
    filter: drop-shadow(0 0 12px rgba(255,107,43,0.4));
}

.floor-table .table-body {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    /* Rich visible fill for both themes */
    background: linear-gradient(145deg, #2a2a3e, #1e1e2f);
    border: 2.5px solid rgba(255, 255, 255, 0.18);
    position: relative;
    z-index: 2;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 2px 8px rgba(0,0,0,0.4);
}

/* Light theme override */
[data-theme="light"] .floor-table .table-body,
:root:not([data-theme="dark"]) .floor-table .table-body {
    background: linear-gradient(145deg, #eef2ff, #dde5ff);
    border-color: rgba(99, 102, 241, 0.35);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 2px 8px rgba(0,0,0,0.12);
}

/* Default (no status) table */
.floor-table .table-body {
    border-color: rgba(255, 255, 255, 0.22);
}

/* Available: green tint */
.floor-table.available .table-body {
    background: linear-gradient(145deg, #1a3a2a, #162e22);
    border-color: #27ae60;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 0 12px rgba(39,174,96,0.25), 0 2px 8px rgba(0,0,0,0.4);
}

[data-theme="light"] .floor-table.available .table-body,
:root:not([data-theme="dark"]) .floor-table.available .table-body {
    background: linear-gradient(145deg, #d4f5e2, #b8edce);
    border-color: #27ae60;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 0 12px rgba(39,174,96,0.2), 0 2px 8px rgba(0,0,0,0.1);
}

/* Occupied: red tint */
.floor-table.occupied .table-body {
    background: linear-gradient(145deg, #3a1a1a, #2e1616);
    border-color: #e74c3c;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 0 12px rgba(231,76,60,0.25), 0 2px 8px rgba(0,0,0,0.4);
}

[data-theme="light"] .floor-table.occupied .table-body,
:root:not([data-theme="dark"]) .floor-table.occupied .table-body {
    background: linear-gradient(145deg, #fde8e8, #f9d0d0);
    border-color: #e74c3c;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 0 12px rgba(231,76,60,0.2), 0 2px 8px rgba(0,0,0,0.1);
}

.floor-table .table-label {
    font-size: 11px;
    font-weight: 800;
    color: #fff;
    line-height: 1;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
    letter-spacing: 0.3px;
}

[data-theme="light"] .floor-table .table-label,
:root:not([data-theme="dark"]) .floor-table .table-label {
    color: #1e1e3f;
    text-shadow: none;
}

.floor-table .table-cap {
    font-size: 9px;
    font-weight: 600;
    color: rgba(255,255,255,0.6);
    margin-top: 3px;
    letter-spacing: 0.2px;
}

[data-theme="light"] .floor-table .table-cap,
:root:not([data-theme="dark"]) .floor-table .table-cap {
    color: rgba(30,30,63,0.55);
}

/* Round table */
.floor-table.round .table-body {
    border-radius: 50%;
    width: 80px;
    height: 80px;
}

/* Rect table */
.floor-table.rect .table-body {
    border-radius: 10px;
    width: 110px;
    height: 70px;
}

/* Seats */
.floor-table .seat {
    position: absolute;
    width: 18px;
    height: 18px;
    background: #2d2d45;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    z-index: 1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

[data-theme="light"] .floor-table .seat,
:root:not([data-theme="dark"]) .floor-table .seat {
    background: #c8cef8;
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.floor-table.available .seat {
    border-color: #27ae60;
    background: rgba(39,174,96,0.3);
    box-shadow: 0 0 6px rgba(39,174,96,0.3), 0 2px 4px rgba(0,0,0,0.3);
}

[data-theme="light"] .floor-table.available .seat,
:root:not([data-theme="dark"]) .floor-table.available .seat {
    background: rgba(39,174,96,0.2);
    box-shadow: 0 0 4px rgba(39,174,96,0.2), 0 1px 3px rgba(0,0,0,0.1);
}

.floor-table.occupied .seat {
    border-color: #e74c3c;
    background: rgba(231,76,60,0.3);
    box-shadow: 0 0 6px rgba(231,76,60,0.3), 0 2px 4px rgba(0,0,0,0.3);
}

[data-theme="light"] .floor-table.occupied .seat,
:root:not([data-theme="dark"]) .floor-table.occupied .seat {
    background: rgba(231,76,60,0.2);
    box-shadow: 0 0 4px rgba(231,76,60,0.2), 0 1px 3px rgba(0,0,0,0.1);
}

/* Legend */
.floor-legend {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 10px 20px;
    background: var(--card);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 12px;
    color: var(--text-muted);
}

.floor-legend-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
}

.sidebar-delete-btn {
    background: transparent;
    border: 1px solid #e74c3c;
    color: #e74c3c;
    border-radius: 8px;
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: var(--transition);
    font-family: inherit;
}

.sidebar-delete-btn:hover {
    background: rgba(231, 76, 60, 0.1);
}

.floor-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    color: var(--text-muted);
}

.floor-empty-state i { font-size: 48px; opacity: 0.2; }
.floor-empty-state p { font-size: 14px; }
