/* CA Tower Admin Panel — Enhanced UI v20.26.05.11.1 */
:root {
    --maroon: #6B1A1A;
    --maroon-dark: #4d1313;
    --maroon-light: #8a2929;
    --gold: #C9A227;
    --gold-light: #e0bc4a;
    --gold-pale: #fdf3d0;
    --cream: #FBF7EF;
    --cream-dark: #f3ecda;
    --white: #ffffff;
    --text: #2a2a2a;
    --text-light: #666;
    --border: #e0d8c2;
    --success: #2e7d32;
    --warning: #ed6c02;
    --danger: #c62828;
    --info: #0288d1;
    --shadow: 0 2px 8px rgba(107, 26, 26, 0.08);
    --shadow-md: 0 4px 12px rgba(107, 26, 26, 0.12);
    --shadow-lg: 0 8px 24px rgba(107, 26, 26, 0.18);
    --radius: 10px;
    --radius-sm: 6px;
    --sidebar-w: 260px;
    --transition: 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: 'Manrope', -apple-system, sans-serif; color: var(--text); background: var(--cream); line-height: 1.5; }
h1, h2, h3, h4 { font-family: 'Cormorant Garamond', serif; color: var(--maroon); font-weight: 600; }

/* ============ LOADING ============ */
.loading-screen { display: flex; align-items: center; justify-content: center; height: 100vh; background: var(--cream); }
.loading-inner { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.loading-text { font-family: 'Cormorant Garamond', serif; font-size: 20px; color: var(--maroon); font-weight: 600; }
.spinner { border: 3px solid var(--cream-dark); border-top-color: var(--maroon); border-radius: 50%; width: 36px; height: 36px; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ LOGIN PAGE ============ */
.login-page {
    display: flex; align-items: stretch; min-height: 100vh;
}
.login-brand {
    flex: 1; background: linear-gradient(160deg, var(--maroon-dark) 0%, var(--maroon) 60%, #8a2929 100%);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 48px; gap: 24px;
}
.login-brand-logo { width: 160px; height: auto; border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,0.4); }
.login-brand-title { font-family: 'Cormorant Garamond', serif; font-size: 36px; font-weight: 700; color: var(--gold); text-align: center; line-height: 1.2; }
.login-brand-sub { font-size: 14px; color: rgba(251,247,239,0.7); text-align: center; font-style: italic; }
.login-panel {
    width: 420px; background: var(--cream); display: flex; flex-direction: column;
    align-items: center; justify-content: center; padding: 48px 40px;
}
.login-panel-title { font-size: 26px; color: var(--maroon); margin-bottom: 8px; }
.login-panel-sub { font-size: 13px; color: var(--text-light); margin-bottom: 32px; }
.login-panel form { display: flex; flex-direction: column; gap: 18px; width: 100%; }
.form-error { background: #fff0f0; color: var(--danger); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; border-left: 3px solid var(--danger); }
@media (max-width: 700px) {
    .login-brand { display: none; }
    .login-panel { width: 100%; padding: 32px 24px; }
}

/* ============ LAYOUT ============ */
.app-layout { display: flex; min-height: 100vh; }

/* ---- SIDEBAR ---- */
.sidebar {
    width: var(--sidebar-w); background: var(--maroon); color: var(--cream);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
    transition: width var(--transition);
    box-shadow: 4px 0 16px rgba(0,0,0,0.15);
}
.sidebar-header {
    padding: 20px 18px; border-bottom: 1px solid rgba(251,247,239,0.12);
    display: flex; align-items: center; gap: 12px;
}
.sidebar-logo-img { width: 44px; height: 44px; object-fit: contain; border-radius: 8px; flex-shrink: 0; }
.sidebar-logo-text { display: flex; flex-direction: column; }
.sidebar-logo-name { font-family: 'Cormorant Garamond', serif; font-size: 18px; font-weight: 700; color: var(--gold); line-height: 1.1; }
.sidebar-tagline { font-size: 10px; color: rgba(251,247,239,0.6); margin-top: 2px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 11px; padding: 11px 18px;
    color: rgba(251,247,239,0.8); text-decoration: none; font-size: 14px;
    transition: all var(--transition); border-left: 3px solid transparent;
    border-radius: 0 6px 6px 0; margin: 1px 8px 1px 0;
}
.sidebar-nav a:hover { background: rgba(251,247,239,0.06); color: var(--cream); border-left-color: rgba(201,162,39,0.5); }
.sidebar-nav a.active { background: rgba(201,162,39,0.18); color: var(--gold); border-left-color: var(--gold); font-weight: 600; }
.nav-icon { width: 22px; text-align: center; font-size: 16px; flex-shrink: 0; }
.sidebar-footer { padding: 14px 18px; border-top: 1px solid rgba(251,247,239,0.1); }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sidebar-user-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gold); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: var(--maroon); flex-shrink: 0; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 10px; color: rgba(251,247,239,0.6); text-transform: uppercase; letter-spacing: 0.5px; }
.sidebar-footer-btns { display: flex; gap: 8px; }
.sidebar-footer-btns button {
    flex: 1; background: rgba(251,247,239,0.08); border: 1px solid rgba(251,247,239,0.2);
    color: rgba(251,247,239,0.8); padding: 7px 10px; border-radius: var(--radius-sm);
    font-size: 11px; cursor: pointer; transition: all var(--transition); font-family: inherit;
}
.sidebar-footer-btns button:hover { background: rgba(251,247,239,0.15); color: var(--cream); }

/* ---- TOP BAR ---- */
.topbar {
    background: white; border-bottom: 1px solid var(--border);
    padding: 0 24px; height: 56px; display: flex; align-items: center;
    justify-content: space-between; box-shadow: var(--shadow); position: sticky; top: 0; z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.mobile-menu-btn { display: none; background: none; border: none; color: var(--maroon); font-size: 22px; cursor: pointer; padding: 4px 8px; }
.topbar-title { font-size: 20px; color: var(--maroon); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-logo { height: 36px; width: auto; }

/* ---- MAIN ---- */
.main-wrapper { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.main { flex: 1; padding: 28px 32px; overflow-x: auto; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 30px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ CARDS ============ */
.card { background: white; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-title { font-size: 16px; color: var(--maroon); font-weight: 600; }
.card-grid { display: grid; gap: 16px; }
.card-grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.card-grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.card-grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.stat-card {
    background: white; border-radius: var(--radius); padding: 18px 20px;
    box-shadow: var(--shadow); border-top: 4px solid var(--maroon);
    transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card.gold { border-top-color: var(--gold); }
.stat-card.success { border-top-color: var(--success); }
.stat-card.warning { border-top-color: var(--warning); }
.stat-card.danger { border-top-color: var(--danger); }
.stat-card .label { font-size: 11px; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 700; }
.stat-card .value { font-size: 26px; font-weight: 700; color: var(--maroon); margin-top: 6px; font-family: 'Cormorant Garamond', serif; }
.stat-card .sub { font-size: 12px; color: var(--text-light); margin-top: 4px; }

/* ============ ROOM CARDS ============ */
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.room-card {
    background: white; border-radius: var(--radius); box-shadow: var(--shadow);
    overflow: hidden; cursor: pointer; transition: all var(--transition);
    border-top: 4px solid var(--border);
}
.room-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.room-card.available { border-top-color: var(--success); }
.room-card.occupied { border-top-color: var(--warning); }
.room-card.cleaning { border-top-color: var(--info); }
.room-card.maintenance { border-top-color: var(--danger); }
.room-card.blocked { border-top-color: #9e9e9e; }
.room-card-body { padding: 16px; }
.room-card-no { font-family: 'Cormorant Garamond', serif; font-size: 28px; font-weight: 700; color: var(--maroon); line-height: 1; }
.room-card-type { font-size: 12px; color: var(--text-light); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
.room-card-rate { font-size: 14px; color: var(--text); margin-top: 8px; font-weight: 600; }
.room-card-floor { font-size: 12px; color: var(--text-light); }
.room-card-footer { padding: 10px 16px; background: var(--cream); display: flex; align-items: center; justify-content: space-between; }

/* ============ FORMS ============ */
.form-group { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.form-group label { font-size: 12px; font-weight: 700; color: var(--maroon); text-transform: uppercase; letter-spacing: 0.4px; }
.form-group input, .form-group select, .form-group textarea {
    padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    background: white; font-size: 14px; font-family: inherit; transition: border var(--transition), box-shadow var(--transition);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--maroon); box-shadow: 0 0 0 3px rgba(107,26,26,0.08);
}
.form-row { display: flex; gap: 14px; }
.form-row > * { flex: 1; min-width: 0; }
textarea { resize: vertical; min-height: 80px; }
.form-section { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: none; }
.form-section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; color: var(--gold); letter-spacing: 0.6px; margin-bottom: 14px; }

/* ============ BUTTONS ============ */
.btn {
    padding: 10px 20px; border: none; border-radius: var(--radius-sm); font-size: 14px;
    font-weight: 600; cursor: pointer; transition: all var(--transition); font-family: inherit;
    display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--maroon); color: var(--cream); }
.btn-primary:hover:not(:disabled) { background: var(--maroon-dark); box-shadow: 0 4px 12px rgba(107,26,26,0.3); }
.btn-gold { background: var(--gold); color: var(--maroon); }
.btn-gold:hover:not(:disabled) { background: var(--gold-light); }
.btn-secondary { background: var(--cream-dark); color: var(--maroon); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #a01f1f; }
.btn-outline { background: transparent; color: var(--maroon); border: 1.5px solid var(--maroon); }
.btn-outline:hover:not(:disabled) { background: var(--maroon); color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; }

/* ============ TABLES ============ */
.table-wrap { overflow-x: auto; background: white; border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
table th {
    background: var(--maroon); padding: 12px 16px; text-align: left;
    font-size: 11px; font-weight: 700; color: var(--gold); text-transform: uppercase;
    letter-spacing: 0.6px; white-space: nowrap;
}
table th:first-child { border-radius: var(--radius-sm) 0 0 0; }
table th:last-child { border-radius: 0 var(--radius-sm) 0 0; }
table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
table tr:hover td { background: var(--cream); }
table tr:last-child td { border-bottom: none; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-mono { font-family: 'Courier New', monospace; font-size: 13px; }

/* ============ BADGES ============ */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; }
.badge-success { background: #e8f5e9; color: var(--success); }
.badge-warning { background: #fff3e0; color: var(--warning); }
.badge-danger { background: #ffebee; color: var(--danger); }
.badge-info { background: #e1f5fe; color: var(--info); }
.badge-default { background: var(--cream-dark); color: var(--text-light); }
.badge-gold { background: var(--gold-pale); color: #7a5c00; }

/* ============ FILTERS ============ */
.filters {
    background: white; padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow);
    margin-bottom: 16px; display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
}
.filters .form-group { flex: 0 0 auto; min-width: 130px; }
.filters .form-group label { font-size: 10px; }
.filters .form-group input, .filters .form-group select { padding: 7px 10px; font-size: 13px; }

/* ============ MODAL ============ */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; animation: fadeIn 0.15s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { background: white; border-radius: 14px; max-width: 620px; width: 100%; max-height: 90vh; overflow-y: auto; animation: slideUp 0.2s; box-shadow: var(--shadow-lg); }
.modal-large { max-width: 920px; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { padding: 20px 24px; border-bottom: 2px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: linear-gradient(to right, var(--cream), white); border-radius: 14px 14px 0 0; }
.modal-header h2 { font-size: 22px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.modal-close { background: var(--cream-dark); border: none; font-size: 20px; cursor: pointer; color: var(--maroon); width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: background var(--transition); flex-shrink: 0; }
.modal-close:hover { background: var(--border); }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; background: var(--cream); border-radius: 0 0 14px 14px; }

/* ============ TOAST ============ */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
    background: white; padding: 14px 20px; border-radius: var(--radius); box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--maroon); min-width: 280px; max-width: 360px;
    animation: slideIn 0.3s; font-size: 14px;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--info); }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============ PAGINATION ============ */
.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding: 12px 16px; background: white; border-radius: var(--radius); box-shadow: var(--shadow); }
.pagination-info { font-size: 13px; color: var(--text-light); }
.pagination-buttons { display: flex; gap: 8px; }

/* ============ EMPTY STATE ============ */
.empty { text-align: center; padding: 56px 20px; color: var(--text-light); }
.empty-icon { font-size: 52px; opacity: 0.35; margin-bottom: 12px; }
.empty-msg { font-size: 15px; margin-bottom: 6px; }

/* ============ AUDIT TIMELINE ============ */
.audit-timeline { list-style: none; padding: 0; }
.audit-timeline li { padding: 14px 0; border-bottom: 1px solid var(--border); }
.audit-timeline li:last-child { border-bottom: none; }
.audit-action { font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 4px; display: inline-block; }
.audit-action.create { background: #e8f5e9; color: var(--success); }
.audit-action.update { background: #fff3e0; color: var(--warning); }
.audit-action.delete { background: #ffebee; color: var(--danger); }
.audit-meta { font-size: 12px; color: var(--text-light); margin-top: 4px; display: block; }
.audit-changes { margin-top: 8px; font-family: monospace; font-size: 12px; background: var(--cream); padding: 8px 12px; border-radius: 4px; }

/* ============ QUICK ACTIONS ============ */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.quick-action-btn {
    background: white; border: 2px solid var(--border); border-radius: var(--radius);
    padding: 18px 12px; text-align: center; cursor: pointer; transition: all var(--transition);
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    color: var(--maroon); font-weight: 600; font-size: 13px; text-decoration: none;
}
.quick-action-btn:hover { border-color: var(--gold); background: var(--gold-pale); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.quick-action-btn .qa-icon { font-size: 28px; }

/* ============ BILLING SUMMARY ============ */
.bill-summary-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.bill-summary-table td { padding: 8px 0; border-bottom: 1px solid var(--border); }
.bill-summary-table tr:last-child td { border-bottom: none; }
.bill-summary-table .total-row td { font-size: 16px; font-weight: 700; padding-top: 10px; }

/* ============ UTILITY ============ */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.p-3 { padding: 12px; } .p-4 { padding: 16px; }
.text-muted { color: var(--text-light); }
.text-sm { font-size: 13px; } .text-xs { font-size: 12px; }
.text-lg { font-size: 18px; }
.font-bold { font-weight: 700; }
.text-maroon { color: var(--maroon); }
.text-gold { color: var(--gold); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.d-none { display: none; }
.w-full { width: 100%; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
hr.divider { border-top: 1px solid var(--border); }

/* Info box */
.info-box { background: var(--cream); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; font-size: 13px; }
.info-box.gold { background: var(--gold-pale); border-color: var(--gold); }
.info-box.danger { background: #ffebee; border-color: var(--danger); }

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
    .sidebar { position: fixed; left: -260px; z-index: 200; transition: left var(--transition); box-shadow: none; }
    .sidebar.mobile-open { left: 0; box-shadow: var(--shadow-lg); }
    .mobile-menu-btn { display: flex !important; align-items: center; justify-content: center; }
    .main-wrapper { width: 100%; }
    .main { padding: 16px; }
    .form-row { flex-direction: column; }
    .card-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .page-header { flex-direction: column; align-items: flex-start; }
    .quick-actions { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 500px) {
    .card-grid-4 { grid-template-columns: 1fr 1fr; }
    .quick-actions { grid-template-columns: repeat(2, 1fr); }
    .modal-footer { flex-direction: column; }
    .modal-footer .btn { width: 100%; justify-content: center; }
}

/* ── Settings page additions ─────────────────────────── */
.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted, #888);
    margin-top: 3px;
}
.alert-info {
    background: #e8f0fe;
    border-left: 4px solid var(--gold, #C9A227);
    border-radius: 6px;
    padding: 12px 16px;
    color: #333;
}

/* Toggle switch */
.toggle-switch { position: relative; display: inline-block; width: 46px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ccc; border-radius: 24px; transition: .3s;
}
.toggle-slider:before {
    position: absolute; content: "";
    height: 18px; width: 18px; left: 3px; bottom: 3px;
    background: white; border-radius: 50%; transition: .3s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--maroon, #6B1A1A); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(22px); }
