/* ============================================================
   style.css — Student Hostel Management System
   Mobile-first, single stylesheet.
   Brand color is set at runtime via --brand-color CSS variable.
   ============================================================ */

/* ── CSS Variables ──────────────────────────────────────────────────────────── */
:root {
    --brand-color: #0d6efd;        /* overridden dynamically in <head> */
    --sidebar-width: 240px;
    --navbar-height: 54px;
    --mobile-nav-height: 60px;
    --sidebar-bg: #1e2a3a;
    --sidebar-text: rgba(255,255,255,.85);
    --sidebar-hover: rgba(255,255,255,.12);
    --sidebar-active-bg: rgba(255,255,255,.18);
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f4f6fb;
    color: #333;
    min-height: 100vh;
}

/* ── Brand helpers ──────────────────────────────────────────────────────────── */
.brand-bg        { background-color: var(--brand-color) !important; }
.brand-text      { color: var(--brand-color) !important; }
.brand-border    { border-color: var(--brand-color) !important; }

/* ── App layout wrapper ─────────────────────────────────────────────────────── */
.app-wrapper {
    min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    min-height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-brand {
    background: rgba(0,0,0,.15);
    min-height: var(--navbar-height);
}
.sidebar-brand:hover { background: rgba(0,0,0,.2); }

.sidebar-logo {
    height: 32px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-size: .85rem;
    line-height: 1.2;
    white-space: normal;
    word-break: break-word;
}

.sidebar-divider {
    border-color: rgba(255,255,255,.1);
    margin: 0;
}

.sidebar-section-label {
    display: block;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .08em;
    color: rgba(255,255,255,.4);
    text-transform: uppercase;
    margin-top: .25rem;
}

.sidebar-link {
    color: var(--sidebar-text);
    border-radius: 6px;
    padding: .45rem .75rem;
    font-size: .875rem;
    transition: background .15s, color .15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-link:hover  { background: var(--sidebar-hover); color: #fff; }
.sidebar-link.active {
    background: var(--brand-color);
    color: #fff;
    font-weight: 600;
}

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,.1);
    font-size: .8rem;
}

/* ── Main column ────────────────────────────────────────────────────────────── */
.main-column {
    min-width: 0;   /* prevent flex overflow */
}

/* ── Top navbar ─────────────────────────────────────────────────────────────── */
.top-navbar {
    height: var(--navbar-height);
    background: #fff;
    border-bottom: 1px solid #e5e9f0;
    position: sticky;
    top: 0;
    z-index: 99;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: #555;
}
.sidebar-toggle:hover { color: var(--brand-color); }

.navbar-user-btn {
    background: #f0f2f5;
    border: 1px solid #e0e3ea;
    border-radius: 8px;
    padding: .3rem .6rem;
    color: #333;
    transition: background .15s;
}
.navbar-user-btn:hover { background: #e4e7ee; }

/* ── Main content ───────────────────────────────────────────────────────────── */
.main-content {
    /* Extra bottom padding on mobile so content isn't hidden behind bottom nav */
    padding-bottom: calc(var(--mobile-nav-height) + 1rem);
}
@media (min-width: 992px) {
    .main-content { padding-bottom: 1rem; }
}

/* ── App footer ─────────────────────────────────────────────────────────────── */
.app-footer {
    background: #fff;
    border-top: 1px solid #e5e9f0;
    font-size: .78rem;
}

/* ── Mobile bottom nav ──────────────────────────────────────────────────────── */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-height);
    background: #fff;
    border-top: 1px solid #e5e9f0;
    z-index: 200;
    box-shadow: 0 -2px 8px rgba(0,0,0,.08);
    justify-content: space-around;
    align-items: center;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 2px;
    padding: 6px 4px;
    text-decoration: none;
    color: #888;
    font-size: .6rem;
    font-weight: 500;
    transition: color .15s;
    min-width: 0;
}
.mobile-nav-item i { font-size: 1.25rem; }
.mobile-nav-item.active, .mobile-nav-item:active {
    color: var(--brand-color);
}
.mobile-nav-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* ── Buttons — override Bootstrap primary with brand color ───────────────────── */
.btn-primary {
    background-color: var(--brand-color) !important;
    border-color: var(--brand-color) !important;
    color: #fff !important;
}
.btn-primary:hover, .btn-primary:focus {
    filter: brightness(0.9);
}
.btn-outline-primary {
    color: var(--brand-color) !important;
    border-color: var(--brand-color) !important;
}
.btn-outline-primary:hover {
    background-color: var(--brand-color) !important;
    color: #fff !important;
}

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge.bg-primary { background-color: var(--brand-color) !important; }

.badge-role-superadmin { background: #6f42c1; color: #fff; padding: .2em .5em; border-radius: 4px; font-size: .7rem; }
.badge-role-admin      { background: #0d6efd; color: #fff; padding: .2em .5em; border-radius: 4px; font-size: .7rem; }
.badge-role-user       { background: #6c757d; color: #fff; padding: .2em .5em; border-radius: 4px; font-size: .7rem; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.stat-card {
    border-left: 4px solid var(--brand-color);
    border-radius: 8px;
    transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.stat-card .stat-icon {
    font-size: 2rem;
    opacity: .6;
}

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrapper {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.table thead th {
    background: #f8f9fc;
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #555;
    border-bottom: 2px solid #e5e9f0;
    white-space: nowrap;
}
.table tbody tr:hover { background: #f9fbff; }

/* ── Status badges ───────────────────────────────────────────────────────────── */
.status-in_hostel  { background: #d1fae5; color: #065f46; border-radius: 12px; padding: .2em .65em; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.status-at_village { background: #fef9c3; color: #713f12; border-radius: 12px; padding: .2em .65em; font-size: .78rem; font-weight: 600; white-space: nowrap; }

.severity-mild     { background: #dbeafe; color: #1e40af; border-radius: 12px; padding: .2em .65em; font-size: .78rem; }
.severity-moderate { background: #fef3c7; color: #92400e; border-radius: 12px; padding: .2em .65em; font-size: .78rem; }
.severity-severe   { background: #fee2e2; color: #991b1b; border-radius: 12px; padding: .2em .65em; font-size: .78rem; }

/* ── Login page ─────────────────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--brand-color) 0%, #1a3a6b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.login-card {
    width: 100%;
    max-width: 400px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.login-logo {
    max-height: 60px;
    object-fit: contain;
}

/* ── Page header ─────────────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1.25rem;
}
.page-header h1 { font-size: 1.3rem; font-weight: 700; margin: 0; }

/* ── Form controls ──────────────────────────────────────────────────────────── */
.form-label { font-weight: 600; font-size: .875rem; }
.form-control:focus, .form-select:focus {
    border-color: var(--brand-color);
    box-shadow: 0 0 0 .2rem rgba(13,110,253,.15);
}

/* ── MC image thumbnail ─────────────────────────────────────────────────────── */
.mc-thumb {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    object-fit: contain;
}

/* ── Availability toggle button ─────────────────────────────────────────────── */
.toggle-status-btn { min-width: 130px; font-size: .8rem; }

/* ── Colour picker preview ──────────────────────────────────────────────────── */
.color-preview-box {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    display: inline-block;
    vertical-align: middle;
}

/* ── Pagination ─────────────────────────────────────────────────────────────── */
.pagination .page-link {
    color: var(--brand-color);
}
.pagination .page-item.active .page-link {
    background-color: var(--brand-color);
    border-color: var(--brand-color);
    color: #fff;
}

/* ── Search bar ─────────────────────────────────────────────────────────────── */
.search-bar { max-width: 300px; }

/* ── Responsive utilities ───────────────────────────────────────────────────── */
@media (max-width: 575.98px) {
    .page-header { flex-direction: column; align-items: flex-start; }
    .search-bar  { max-width: 100%; width: 100%; }
    .table thead { display: none; }
    .table tbody tr { display: block; border-bottom: 2px solid #dee2e6; margin-bottom: .5rem; }
    .table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: .4rem .75rem;
        font-size: .85rem;
        border: none;
        border-bottom: 1px solid #f0f0f0;
    }
    .table tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: .75rem;
        color: #666;
        text-transform: uppercase;
        letter-spacing: .03em;
        margin-right: .5rem;
        flex-shrink: 0;
    }
}
