/* ============================================================
   HostelPro — Main Stylesheet
   ============================================================ */

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --sidebar-width: 240px;
    --topbar-height: 56px;
    --sidebar-bg: #1e1b4b;
    --sidebar-text: #c7d2fe;
    --sidebar-hover: rgba(255,255,255,0.08);
    --sidebar-active: rgba(255,255,255,0.15);
    --body-bg: #f8fafc;
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--body-bg);
    margin: 0;
    font-size: 14px;
    color: #1e293b;
}

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1040;
    transition: transform 0.25s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    padding: 1.25rem 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    letter-spacing: 0.3px;
}

.sidebar-close {
    color: rgba(255,255,255,0.6);
    font-size: 1rem;
    line-height: 1;
    transition: color 0.15s;
}
.sidebar-close:hover { color: #fff; }

.sidebar-nav {
    padding: 0.5rem 0;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 0;
    transition: all 0.15s;
    font-size: 0.875rem;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
    border-left: 3px solid #818cf8;
}

.sidebar-nav .nav-link i {
    width: 18px;
    text-align: center;
    font-size: 1rem;
}

.nav-section {
    padding: 0.75rem 1rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.35);
}

/* ── Main Content ── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin 0.25s ease;
}

/* ── Top bar ── */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1030;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle {
    color: #64748b;
    padding: 0.25rem;
}

/* ── Page Content ── */
.page-content {
    padding: 1.5rem;
}

/* ── Stat Cards ── */
.stat-card {
    border-radius: 12px;
    padding: 1.25rem;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
}

.stat-blue   { background: linear-gradient(135deg, #4f46e5, #6366f1); }
.stat-green  { background: linear-gradient(135deg, #16a34a, #22c55e); }
.stat-red    { background: linear-gradient(135deg, #dc2626, #ef4444); }
.stat-purple { background: linear-gradient(135deg, #7c3aed, #8b5cf6); }
.stat-orange { background: linear-gradient(135deg, #ea580c, #f97316); }

.stat-icon { font-size: 1.8rem; opacity: 0.8; margin-bottom: 0.5rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 0.8rem; opacity: 0.85; margin-top: 0.25rem; }

/* ── Cards ── */
.card {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.75rem 1rem;
    border-radius: 10px 10px 0 0 !important;
}

/* ── Auth Layout ── */
.auth-body {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.auth-wrapper {
    width: 100%;
    max-width: 420px;
}

.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.auth-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}

/* ── Room Cards ── */
.room-card {
    border-width: 2px;
    border-radius: 10px;
    transition: transform 0.15s, box-shadow 0.15s;
}

.room-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

/* ── Info Groups ── */
.info-group {
    margin-bottom: 1rem;
}

.info-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 0.2rem;
}

/* ── Receipt ── */
.receipt-card {
    border: 2px solid #e2e8f0;
    font-family: 'Courier New', monospace;
}

/* ── Tables ── */
.table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
}

.table-hover tbody tr:hover {
    background-color: #f1f5f9;
}

/* ── Badges ── */
.badge { font-size: 0.7rem; padding: 0.3em 0.6em; font-weight: 500; }

/* ── Alerts ── */
.alert { border-radius: 8px; font-size: 0.875rem; }

/* ── Form ── */
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(79,70,229,0.15);
}
.form-label { font-size: 0.8125rem; margin-bottom: 0.3rem; }

/* ── Responsive table wrapper (applied globally) ── */
.table-responsive { -webkit-overflow-scrolling: touch; }
.table td, .table th { vertical-align: middle; white-space: nowrap; }
.table td.text-wrap, .table th.text-wrap { white-space: normal; }

/* ── Stat cards — better touch targets on mobile ── */
.stat-card { border-radius: 12px; }

/* ── Top action bar (page header buttons) ── */
.page-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }
.page-header h4 { margin: 0; }
.page-header .actions { display: flex; gap: 0.375rem; flex-wrap: wrap; }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* ── PWA Install Banner ── */
#pwaInstallBanner {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

/* ── Print ── */
@media print {
    .sidebar, .topbar, .d-print-none { display: none !important; }
    .main-content { margin-left: 0; }
    .page-content { padding: 0; }
    .card { border: none; box-shadow: none; }
}

/* ── Sidebar Overlay (mobile) ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1039;
    cursor: pointer;
}
.sidebar-overlay.show { display: block; }

/* ── Mobile ── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1040;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }
    .main-content { margin-left: 0; }
    .stat-value { font-size: 1.2rem; }
    .page-content { padding: 0.875rem; }
    .topbar { padding: 0 0.875rem; }
    .card { border-radius: 8px; }

    /* Tables: allow horizontal scroll, prevent text overflow */
    .table td, .table th { font-size: 0.8rem; padding: 0.4rem 0.5rem; }

    /* Shrink page header buttons */
    .page-header .btn, .d-flex.gap-2 > .btn { font-size: 0.75rem; padding: 0.25rem 0.5rem; }
    .page-header .btn i, .d-flex.gap-2 > .btn i { margin-right: 0 !important; }
    .page-header .btn span.d-md-none { display: none !important; }

    /* Stat label font */
    .stat-label { font-size: 0.7rem; }
    .badge { font-size: 0.65rem; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Tom Select ── */
.ts-wrapper.form-select-sm .ts-control {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    min-height: calc(1.5em + 0.5rem + 2px);
}
.ts-wrapper.form-select-sm .ts-control .item {
    font-size: 0.875rem;
}
/* Match app primary colour for focus ring */
.ts-wrapper .ts-control:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(79,70,229,0.15);
}
.ts-dropdown .option.selected,
.ts-dropdown .option:hover {
    background-color: var(--primary);
}

/* ── Utilities ── */
.font-monospace { font-family: 'Courier New', monospace; }
.fs-07 { font-size: 0.7rem; }
.cursor-pointer { cursor: pointer; }
.btn-xs { padding: 0.1rem 0.4rem; font-size: 0.7rem; }
