/**
 * HOSPITAL MANAGEMENT SYSTEM (HMS)
 * Modern Enterprise Clinical SaaS Design System
 * Clean, Neat, Standardized Typography & High-Precision Layout
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Brand & Clinical Color Palette */
    --hms-primary: #0284c7;
    --hms-primary-dark: #0369a1;
    --hms-primary-light: #eff6ff;
    --hms-primary-border: #bae6fd;
    --hms-secondary: #0d9488;
    --hms-secondary-dark: #0f766e;
    --hms-secondary-light: #f0fdfa;
    
    /* Neutrals */
    --hms-bg: #f8fafc;
    --hms-card-bg: #ffffff;
    --hms-text-main: #0f172a;
    --hms-text-body: #334155;
    --hms-text-muted: #64748b;
    --hms-text-subtle: #94a3b8;
    --hms-border: #e2e8f0;
    --hms-border-focus: #38bdf8;
    --hms-border-subtle: #f1f5f9;
    
    /* Functional Semantic Colors */
    --hms-success: #10b981;
    --hms-success-bg: #ecfdf5;
    --hms-success-text: #047857;
    --hms-warning: #f59e0b;
    --hms-warning-bg: #fffbeb;
    --hms-warning-text: #b45309;
    --hms-danger: #ef4444;
    --hms-danger-bg: #fef2f2;
    --hms-danger-text: #b91c1c;
    --hms-info: #0284c7;
    --hms-info-bg: #f0f9ff;
    --hms-info-text: #0369a1;
    
    /* Dimensions */
    --sidebar-width: 245px;
    --sidebar-collapsed-width: 68px;
    --topbar-height: 56px;
    
    /* Standard Modern Radii */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 12px;
    
    /* Crisp, Subtle Enterprise Shadows */
    --shadow-subtle: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.02);
    --shadow-hover: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.03);
    --shadow-elevated: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 0.875rem; /* Standard 14px */
    line-height: 1.5;
    background-color: var(--hms-bg);
    color: var(--hms-text-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Standard Heading Scale */
h1, h2, h3, h4, h5, h6, .brand-font {
    font-family: inherit;
    color: var(--hms-text-main);
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; }
h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.02em; }
h3 { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.015em; }
h4 { font-size: 1rem; font-weight: 600; }
h5 { font-size: 0.925rem; font-weight: 600; }
h6 { font-size: 0.8125rem; font-weight: 600; }

/* Standard Utility Sizes */
.fs-7 { font-size: 0.8125rem !important; } /* 13px */
.fs-8 { font-size: 0.75rem !important; }   /* 12px */
.fs-9 { font-size: 0.6875rem !important; } /* 11px */

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

/* App Wrapper & Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Top Demo Role Switcher Toolbar */
.demo-role-banner {
    background: #0f172a;
    color: #f8fafc;
    padding: 0.35rem 1.25rem;
    font-size: 0.775rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #1e293b;
    z-index: 1050;
    line-height: 1.4;
}

.demo-role-banner .badge {
    font-size: 0.6875rem;
    padding: 0.2rem 0.5rem;
}

/* Sidebar Navigation */
.app-sidebar {
    width: var(--sidebar-width);
    background: #ffffff;
    border-right: 1px solid var(--hms-border);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.15rem;
    border-bottom: 1px solid var(--hms-border);
    justify-content: space-between;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: var(--hms-text-main);
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--hms-primary), #0ea5e9);
    color: #ffffff;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(2, 132, 199, 0.2);
    flex-shrink: 0;
}

.brand-icon svg {
    width: 17px;
    height: 17px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.65rem;
}

.nav-category {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--hms-text-subtle);
    padding: 0.7rem 0.65rem 0.25rem 0.65rem;
    margin-top: 0.25rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.45rem 0.65rem;
    color: #475569;
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.12s ease;
    margin-bottom: 1px;
}

.sidebar-link i, .sidebar-link svg {
    width: 16px;
    height: 16px;
    color: #64748b;
    flex-shrink: 0;
    transition: color 0.12s ease;
}

.sidebar-link:hover {
    background-color: #f8fafc;
    color: var(--hms-text-main);
}

.sidebar-link:hover i, .sidebar-link:hover svg {
    color: var(--hms-primary);
}

.sidebar-link.active {
    background-color: var(--hms-primary-light);
    color: var(--hms-primary);
    font-weight: 600;
}

.sidebar-link.active i, .sidebar-link.active svg {
    color: var(--hms-primary);
}

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--hms-border);
    background: #fafafa;
}

/* Main Content Area */
.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Top Navbar */
.app-topbar {
    height: var(--topbar-height);
    background: #ffffff;
    border-bottom: 1px solid var(--hms-border);
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
}

.topbar-search {
    position: relative;
    width: 280px;
}

.topbar-search input {
    border-radius: var(--radius-sm);
    padding-left: 2.25rem;
    background-color: #f8fafc;
    border: 1px solid var(--hms-border);
    font-size: 0.8125rem;
    height: 36px;
    color: var(--hms-text-main);
    transition: all 0.15s ease;
}

.topbar-search input:focus {
    background-color: #ffffff;
    border-color: var(--hms-primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
}

.topbar-search .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: #94a3b8;
    pointer-events: none;
}

.user-profile-btn {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: transparent;
    border: 1px solid transparent;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s ease;
}

.user-profile-btn:hover {
    background: #f1f5f9;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    font-size: 0.8125rem;
}

/* Page Content Container */
.page-content {
    padding: 1.25rem 1.5rem;
    flex: 1;
}

/* Clean Cards & Widgets */
.hms-card {
    background: var(--hms-card-bg);
    border: 1px solid var(--hms-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hms-card-hover:hover {
    border-color: #cbd5e1;
    box-shadow: var(--shadow-hover);
}

/* KPI Stat Widgets - Neat, Clean & Standard Sized */
.stat-widget {
    padding: 0.95rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg, .stat-icon i {
    width: 19px;
    height: 19px;
}

.stat-value {
    font-size: 1.35rem; /* Standard ~21px */
    font-weight: 700;
    line-height: 1.2;
    color: var(--hms-text-main);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 0.775rem; /* Standard ~12.4px */
    font-weight: 500;
    color: var(--hms-text-muted);
    line-height: 1.3;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Modern Clean Tables */
.table-responsive-custom {
    border: 1px solid var(--hms-border);
    border-radius: var(--radius-md);
    background: #ffffff;
    overflow: hidden;
}

.hms-table {
    margin-bottom: 0;
    width: 100%;
    vertical-align: middle;
}

.hms-table th {
    background-color: #f8fafc;
    color: #475569;
    font-size: 0.725rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--hms-border);
    white-space: nowrap;
}

.hms-table td {
    padding: 0.65rem 0.85rem;
    font-size: 0.8125rem;
    color: var(--hms-text-main);
    border-bottom: 1px solid #f1f5f9;
}

.hms-table tr:hover td {
    background-color: #f8fafc;
}

/* Status Badges */
.badge {
    padding: 0.25rem 0.55rem;
    font-size: 0.725rem;
    font-weight: 500;
    border-radius: var(--radius-xs);
    letter-spacing: 0.01em;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.badge-success, .bg-success-subtle {
    background-color: var(--hms-success-bg) !important;
    color: var(--hms-success-text) !important;
}

.badge-danger, .bg-danger-subtle {
    background-color: var(--hms-danger-bg) !important;
    color: var(--hms-danger-text) !important;
}

.badge-warning, .bg-warning-subtle {
    background-color: var(--hms-warning-bg) !important;
    color: var(--hms-warning-text) !important;
}

.badge-info, .bg-info-subtle {
    background-color: var(--hms-info-bg) !important;
    color: var(--hms-info-text) !important;
}

.badge-primary, .bg-primary-subtle {
    background-color: var(--hms-primary-light) !important;
    color: var(--hms-primary-dark) !important;
}

.badge-secondary, .bg-secondary-subtle {
    background-color: #f1f5f9 !important;
    color: #475569 !important;
}

/* Clean Buttons */
.btn {
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 0.42rem 0.85rem;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    transition: all 0.15s ease;
}

.btn-primary {
    background: var(--hms-primary);
    border: 1px solid var(--hms-primary);
    color: #ffffff;
    box-shadow: 0 1px 2px rgba(2, 132, 199, 0.2);
}

.btn-primary:hover {
    background: var(--hms-primary-dark);
    border-color: var(--hms-primary-dark);
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(2, 132, 199, 0.25);
}

.btn-teal {
    background: var(--hms-secondary);
    border: 1px solid var(--hms-secondary);
    color: #ffffff;
    box-shadow: 0 1px 2px rgba(13, 148, 136, 0.2);
}

.btn-teal:hover {
    background: var(--hms-secondary-dark);
    border-color: var(--hms-secondary-dark);
    color: #ffffff;
}

.btn-sm {
    font-size: 0.775rem;
    padding: 0.32rem 0.65rem;
}

.btn-sm-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* Clean Bed Grid Cards */
.bed-card {
    border-radius: var(--radius-sm);
    border: 1px solid #e2e8f0;
    padding: 0.85rem;
    background: #ffffff;
    transition: all 0.15s ease;
    position: relative;
}

.bed-card.available {
    border-color: #86efac;
    background: #f0fdf4;
}
.bed-card.occupied {
    border-color: #fca5a5;
    background: #fef2f2;
}
.bed-card.reserved {
    border-color: #fde047;
    background: #fefce8;
}
.bed-card.maintenance {
    border-color: #cbd5e1;
    background: #f8fafc;
}

/* Modals & Forms */
.modal-content {
    border-radius: var(--radius-md);
    border: 1px solid var(--hms-border);
    box-shadow: var(--shadow-elevated);
}

.modal-header {
    border-bottom: 1px solid var(--hms-border);
    padding: 0.9rem 1.25rem;
}

.modal-footer {
    border-top: 1px solid var(--hms-border);
    padding: 0.85rem 1.25rem;
}

.form-label {
    font-weight: 500;
    font-size: 0.8125rem;
    color: #334155;
    margin-bottom: 0.35rem;
}

.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid #cbd5e1;
    padding: 0.45rem 0.75rem;
    font-size: 0.8125rem;
    color: var(--hms-text-main);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--hms-primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
}

/* ====================================================================
   RESPONSIVE DESIGN BREAKPOINTS
   Mobile (< 576px), Tablet (576px - 991px), Desktop (> 992px)
   ==================================================================== */

/* Dim Backdrop for Mobile Drawer */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 1039;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sidebar-backdrop.active {
    opacity: 1;
    visibility: visible;
}

body.sidebar-open {
    overflow: hidden;
}

/* Tablet & Mobile Screens (<= 991.98px) */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        width: 260px !important;
        box-shadow: 4px 0 24px rgba(15, 23, 42, 0.15);
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .app-sidebar.show-mobile {
        transform: translateX(0);
    }
    
    .app-main {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    .app-topbar {
        padding: 0 1rem;
    }
    
    .page-content {
        padding: 1rem;
    }
    
    .stat-widget {
        padding: 0.85rem;
    }
    
    .demo-role-banner {
        padding: 0.35rem 1rem;
    }
}

/* Small Phones & Phablets (<= 575.98px) */
@media (max-width: 575.98px) {
    :root {
        --topbar-height: 52px;
    }
    
    body {
        font-size: 0.8125rem;
    }
    
    .app-topbar {
        padding: 0 0.75rem;
        height: var(--topbar-height);
    }
    
    .page-content {
        padding: 0.75rem;
    }
    
    /* Stat cards on mobile: high-density 2-column grid */
    .stat-widget {
        padding: 0.75rem 0.65rem;
        gap: 0.55rem;
    }
    
    .stat-icon {
        width: 34px;
        height: 34px;
        border-radius: var(--radius-xs);
    }
    
    .stat-icon svg, .stat-icon i {
        width: 16px;
        height: 16px;
    }
    
    .stat-value {
        font-size: 1.15rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    /* Mobile Tables Horizontal Scrolling */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        margin-bottom: 0.5rem;
    }
    
    .hms-table th, .hms-table td {
        padding: 0.5rem 0.65rem;
        font-size: 0.75rem;
    }
    
    /* DataTables controls stack nicely */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        text-align: left !important;
        margin-bottom: 0.5rem;
    }
    
    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
    }
    
    /* Modals on phones */
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-header, .modal-footer {
        padding: 0.75rem 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    /* Demo role banner on phones */
    .demo-role-banner {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.35rem;
        padding: 0.35rem 0.75rem;
    }
    
    .demo-role-banner .dropdown {
        width: 100%;
    }
    
    .demo-role-banner .dropdown button {
        width: 100%;
        text-align: center;
    }
}

/* Printable Sections */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }
    .app-sidebar, .app-topbar, .demo-role-banner, .no-print, .btn, .topbar-search {
        display: none !important;
    }
    .app-main {
        margin-left: 0 !important;
    }
    .page-content {
        padding: 0 !important;
    }
    .print-only {
        display: block !important;
    }
    .hms-card {
        border: none !important;
        box-shadow: none !important;
    }
}
