/* ============================================================
   HOSI360 - Global Stylesheet
   Brand: Gold #F5A623 | Dark #1A1F2E | Clinical white base
   Font: Inter (Google Fonts)
   Makhety Digital Solutions | hosi360.makhety.com
   ============================================================ */

/* ----- CSS CUSTOM PROPERTIES ----- */
:root {
    --gold:         #F5A623;
    --gold-dark:    #D4891A;
    --gold-light:   #FEF3DC;
    --dark:         #1A1F2E;
    --dark-mid:     #2C3347;
    --dark-light:   #3D4560;
    --white:        #FFFFFF;
    --light:        #F8F9FA;
    --light-mid:    #F1F3F7;
    --border:       #E5E8EF;
    --text:         #1A1F2E;
    --text-muted:   #6B7280;
    --text-light:   #9CA3AF;
    --success:      #16A34A;
    --danger:       #DC2626;
    --warning:      #F59E0B;
    --info:         #2563EB;

    --sidebar-w:    260px;
    --topbar-h:     60px;
    --radius:       10px;
    --radius-sm:    6px;
    --shadow:       0 2px 12px rgba(0,0,0,.08);
    --shadow-md:    0 4px 24px rgba(0,0,0,.12);
    --transition:   all .18s ease;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --light:      #111827;
        --light-mid:  #1F2937;
        --border:     #374151;
        --text:       #F9FAFB;
        --text-muted: #9CA3AF;
        --white:      #1F2937;
    }
}
:root[data-theme="dark"] {
    --light:      #111827;
    --light-mid:  #1F2937;
    --border:     #374151;
    --text:       #F9FAFB;
    --text-muted: #9CA3AF;
    --white:      #1F2937;
}

/* ----- RESET / BASE ----- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    scroll-padding-top: env(safe-area-inset-top, 0px);
}

html { box-sizing: border-box; padding-top: env(safe-area-inset-top, 0px); }

body.hosi-app {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--light);
    -webkit-font-smoothing: antialiased;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-dark); }

img { max-width: 100%; }

.fw-600 { font-weight: 600; }

/* ----- LAYOUT ----- */
.hosi-layout {
    display: flex;
    min-height: 100vh;
    padding-top: var(--topbar-h);
}

/* ----- TOPBAR ----- */
.hosi-topbar {
    position: fixed;
    top: env(safe-area-inset-top, 0px);
    left: 0;
    right: 0;
    height: var(--topbar-h);
    background: var(--dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1030;
    border-bottom: 2px solid var(--gold);
}

.hosi-topbar .hosi-icon-btn,
.hosi-topbar .hosi-sidebar-toggle {
    background: transparent;
    border: none;
    color: rgba(255,255,255,.75);
    font-size: 16px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    position: relative;
}
.hosi-topbar .hosi-icon-btn:hover,
.hosi-topbar .hosi-sidebar-toggle:hover {
    background: var(--dark-mid);
    color: #fff;
}

.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--gold);
    color: var(--dark);
    font-size: 9px;
    font-weight: 700;
    border-radius: 100px;
    padding: 1px 5px;
    line-height: 1.4;
}

.hosi-user-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,.15);
    color: #fff;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.hosi-user-btn:hover { background: var(--dark-mid); color: #fff; border-color: var(--gold); }

/* Topbar right-side text must always be light — override Bootstrap .text-muted inside the dark topbar */
.hosi-topbar .text-muted,
.hosi-topbar .hosi-user-btn .text-muted {
    color: rgba(255,255,255,.45) !important;
}
.hosi-topbar .hosi-user-btn .fw-600,
.hosi-topbar .hosi-user-btn .fw-600.small {
    color: #fff;
}
.hosi-topbar .hosi-user-btn .fa-chevron-down {
    color: rgba(255,255,255,.4) !important;
}
.tenant-name-mobile {
    color: #fff;
    font-size: 14px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--gold);
    color: var(--dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.tenant-name-mobile { color: #fff; font-size: 13px; }

/* Notification dropdown */
.notif-dropdown { border: 1px solid var(--border); border-radius: var(--radius); }
.notif-list { max-height: 320px; overflow-y: auto; }
.notif-item {
    display: block;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
    color: var(--text);
}
.notif-item:hover { background: var(--light-mid); }
.notif-item.unread { background: var(--gold-light); }
.notif-title { font-weight: 600; font-size: 13px; }
.notif-msg   { font-size: 12px; color: var(--text-muted); }
.notif-time  { font-size: 11px; color: var(--text-light); margin-top: 2px; }

/* ----- SIDEBAR ----- */
.hosi-sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--dark);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1020;
    display: flex;
    flex-direction: column;
    transition: transform .22s ease;
    scrollbar-width: thin;
    scrollbar-color: var(--dark-mid) transparent;
}
.hosi-sidebar::-webkit-scrollbar { width: 4px; }
.hosi-sidebar::-webkit-scrollbar-track { background: transparent; }
.hosi-sidebar::-webkit-scrollbar-thumb { background: var(--dark-mid); border-radius: 4px; }

/* Sidebar Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}

.sidebar-logo { height: 36px; width: auto; border-radius: 6px; }

.sidebar-logo-text {
    width: 36px;
    height: 36px;
    background: var(--gold);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 900;
    color: var(--dark);
    flex-shrink: 0;
}
.sidebar-logo-text .logo-h  { font-size: 18px; font-weight: 900; }
.sidebar-logo-text .logo-degree { font-size: 10px; margin-top: -8px; }

.sidebar-tenant { min-width: 0; }
.tenant-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tenant-type {
    font-size: 11px;
    color: var(--gold);
    text-transform: capitalize;
}

/* Sidebar Nav */
.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.nav-section-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(255,255,255,.3);
    padding: 14px 20px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 20px;
    color: rgba(255,255,255,.65);
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.nav-item i {
    width: 18px;
    text-align: center;
    font-size: 14px;
    flex-shrink: 0;
}
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    background: var(--gold);
    color: var(--dark);
    font-size: 10px;
    font-weight: 700;
    border-radius: 10px;
    padding: 0 5px;
    margin-left: auto;
}
.nav-item:hover {
    color: #fff;
    background: rgba(255,255,255,.06);
    border-left-color: rgba(245,166,35,.4);
}
.nav-item.active {
    color: var(--gold);
    background: rgba(245,166,35,.1);
    border-left-color: var(--gold);
    font-weight: 600;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}
.sidebar-expiry { margin-bottom: 8px; color: rgba(255,255,255,.4); font-size: 11px; }
.sidebar-logout-btn {
    width: 100%;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.12);
    color: rgba(255,255,255,.65);
    font-size: 13px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.sidebar-logout-btn:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

/* Mobile sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1019;
}
.sidebar-overlay.active { display: block; }

/* ----- MAIN CONTENT AREA ----- */
.hosi-main {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 24px;
    min-width: 0;
}

.page-header-row {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--dark);
    margin: 0;
}
.page-title i { color: var(--gold); }

/* ----- CARDS ----- */
.hosi-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.hosi-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.hosi-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--dark);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.hosi-card-title i { color: var(--gold); font-size: 14px; }

/* ----- STAT CARDS (Dashboard) ----- */
.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--gold);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: var(--gold-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--gold);
    flex-shrink: 0;
}
.stat-icon.green  { background: #DCFCE7; color: var(--success); }
.stat-icon.blue   { background: #DBEAFE; color: var(--info); }
.stat-icon.red    { background: #FEE2E2; color: var(--danger); }
.stat-icon.purple { background: #EDE9FE; color: #7C3AED; }

.stat-value { font-size: 26px; font-weight: 700; color: var(--dark); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ----- BUTTONS ----- */
.btn-gold {
    background: var(--gold);
    color: var(--dark);
    border: none;
    font-weight: 600;
}
.btn-gold:hover { background: var(--gold-dark); color: var(--dark); }

.btn-dark-hosi {
    background: var(--dark);
    color: #fff;
    border: none;
}
.btn-dark-hosi:hover { background: var(--dark-mid); color: #fff; }

/* ----- TABLES ----- */
.hosi-table {
    width: 100%;
    border-collapse: collapse;
}
.hosi-table th {
    background: var(--light-mid);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .5px;
    text-transform: uppercase;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.hosi-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
    vertical-align: middle;
}
.hosi-table tbody tr:hover { background: var(--light-mid); }
.hosi-table tbody tr:last-child td { border-bottom: none; }

/* Responsive table wrapper */
.table-responsive-hosi {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ----- FORMS ----- */
.form-label { font-size: 13px; font-weight: 600; color: var(--dark); }

.form-control, .form-select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    background: var(--white);
    transition: var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(245,166,35,.15);
}

/* ----- BADGES ----- */
.badge { font-size: 11px; font-weight: 600; padding: 4px 8px; border-radius: 100px; }

/* ----- MOBILE BOTTOM NAV ----- */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--dark);
    display: flex;
    align-items: flex-start;
    justify-content: space-around;
    border-top: 2px solid var(--gold);
    z-index: 1010;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,.5);
    font-size: 10px;
    padding: 8px 10px;
    min-width: 50px;
    gap: 3px;
    transition: var(--transition);
    border-top: 2px solid transparent;
}
.mobile-nav-item i { font-size: 18px; }
.mobile-nav-item:hover,
.mobile-nav-item.active {
    color: var(--gold);
    border-top-color: var(--gold);
}

/* Add bottom padding to main content on mobile so nav doesn't cover content */
@media (max-width: 991.98px) {
    .hosi-main {
        margin-left: 0;
        padding: 16px 14px 80px;
    }
    .hosi-sidebar {
        transform: translateX(calc(-1 * var(--sidebar-w)));
    }
    .hosi-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.3);
    }
    .page-title { font-size: 17px; }
}

/* ----- ALERTS ----- */
.alert {
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
}
.alert-success { background: #DCFCE7; color: #15803D; }
.alert-danger   { background: #FEE2E2; color: #B91C1C; }
.alert-warning  { background: #FEF3C7; color: #92400E; }
.alert-info     { background: #DBEAFE; color: #1D4ED8; }

/* ----- PATIENT STATUS CHIPS ----- */
.gender-m { color: var(--info); }
.gender-f { color: #DB2777; }

/* ----- SEARCH BAR ----- */
.hosi-search {
    position: relative;
    max-width: 320px;
}
.hosi-search input {
    padding-left: 36px;
    background: var(--light-mid);
    border: 1px solid var(--border);
}
.hosi-search .search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
    pointer-events: none;
}

/* ----- UTILITY ----- */
.text-gold    { color: var(--gold) !important; }
.bg-gold      { background: var(--gold) !important; }
.bg-dark-hosi { background: var(--dark) !important; }
.border-gold  { border-color: var(--gold) !important; }

.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 48px; color: var(--border); margin-bottom: 16px; display: block; }
.empty-state h5 { font-weight: 600; color: var(--text); }
.empty-state p  { font-size: 13px; }
