/* ============================================================
   Smart Infusion Monitor — Global Stylesheet
   Mobile-First Design + Bottom Navigation
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-primary:    #0f172a;
    --bg-secondary:  #1e293b;
    --bg-card:       rgba(30, 41, 59, 0.9);
    --bg-glass:      rgba(255,255,255,0.05);
    --border:        rgba(255,255,255,0.08);
    --text-primary:  #f1f5f9;
    --text-secondary:#94a3b8;
    --text-muted:    #475569;
    --accent-blue:   #38bdf8;
    --accent-indigo: #6366f1;
    --accent-green:  #22c55e;
    --accent-yellow: #f59e0b;
    --accent-red:    #ef4444;
    --accent-orange: #f97316;
    --sidebar-w:     260px;
    --header-h:      60px;
    --bottom-nav-h:  68px;
    --radius:        16px;
    --radius-sm:     10px;
    --shadow:        0 4px 24px rgba(0,0,0,0.3);
    --shadow-lg:     0 8px 40px rgba(0,0,0,0.4);
    --transition:    all 0.25s ease;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    /* Cegah zoom saat tap input di iOS */
    -webkit-text-size-adjust: 100%;
}

/* ============================================================
   LAYOUT UTAMA
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR — Desktop only
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}
.sidebar-brand .brand-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(56,189,248,0.3);
}
.sidebar-brand .brand-text h2 {
    font-size: 0.88rem; font-weight: 700;
    color: var(--text-primary); line-height: 1.2;
}
.sidebar-brand .brand-text span { font-size: 0.68rem; color: var(--text-muted); }

.sidebar-nav { padding: 0.75rem; flex: 1; }

.nav-section-label {
    font-size: 0.62rem; font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 1px;
    padding: 0.5rem 0.5rem 0.2rem;
    margin-top: 0.4rem;
}
.nav-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem; font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-glass); color: var(--text-primary); }
.nav-item.active {
    background: linear-gradient(135deg, rgba(56,189,248,0.15), rgba(99,102,241,0.15));
    color: var(--accent-blue);
    border: 1px solid rgba(56,189,248,0.2);
}
.nav-item .nav-icon { font-size: 1.1rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .nav-badge {
    margin-left: auto;
    background: var(--accent-red);
    color: #fff; font-size: 0.62rem; font-weight: 700;
    padding: 1px 6px; border-radius: 20px;
    animation: pulse-badge 1.5s infinite;
    min-width: 18px; text-align: center;
}
@keyframes pulse-badge { 0%,100%{opacity:1} 50%{opacity:0.6} }

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.user-info {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    background: var(--bg-glass);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.user-avatar {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem; flex-shrink: 0; font-weight: 700;
}
.user-detail { flex: 1; min-width: 0; }
.user-detail .user-name {
    font-size: 0.78rem; font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-detail .user-role { font-size: 0.68rem; color: var(--text-muted); text-transform: capitalize; }
.btn-logout {
    color: var(--text-muted); text-decoration: none;
    font-size: 1rem; transition: var(--transition);
    padding: 0.25rem;
}
.btn-logout:hover { color: var(--accent-red); }

/* Overlay gelap saat sidebar mobile terbuka */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px);
    z-index: 99;
}
.sidebar-overlay.show { display: block; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    height: var(--header-h);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 1.25rem;
    gap: 0.75rem;
    position: sticky; top: 0; z-index: 50;
}
/* Tombol hamburger — hanya muncul di mobile */
.topbar-menu-btn {
    display: none;
    width: 36px; height: 36px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: 10px;
    align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-secondary);
    font-size: 1.1rem; flex-shrink: 0;
    transition: var(--transition);
}
.topbar-menu-btn:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }

.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 {
    font-size: 1rem; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-title p { font-size: 0.72rem; color: var(--text-muted); }

.topbar-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

.status-dot {
    display: flex; align-items: center; gap: 0.4rem;
    font-size: 0.72rem; color: var(--text-secondary);
}
.dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green);
    animation: blink 2s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.4} }

.btn-icon {
    width: 36px; height: 36px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-secondary);
    transition: var(--transition); text-decoration: none;
    font-size: 1rem; flex-shrink: 0;
}
.btn-icon:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }

/* Page content */
.page-content {
    padding: 1.25rem;
    flex: 1;
    /* Ruang untuk bottom nav di mobile */
}

/* ============================================================
   BOTTOM NAVIGATION — Mobile
   ============================================================ */
.bottom-nav {
    display: none; /* Tersembunyi di desktop */
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-h);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255,255,255,0.1);
    z-index: 90;
    padding: 0 0.5rem;
    padding-bottom: env(safe-area-inset-bottom); /* iPhone notch */
}
.bottom-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 100%;
    max-width: 480px;
    margin: 0 auto;
}
.bn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0.4rem 0.75rem;
    border-radius: 14px;
    text-decoration: none;
    color: var(--text-muted);
    transition: var(--transition);
    position: relative;
    min-width: 52px;
    flex: 1;
}
.bn-item:active { transform: scale(0.92); }
.bn-item.active { color: var(--accent-blue); }
.bn-item.active .bn-icon-wrap {
    background: linear-gradient(135deg, rgba(56,189,248,0.2), rgba(99,102,241,0.2));
    border: 1px solid rgba(56,189,248,0.3);
}
.bn-icon-wrap {
    width: 38px; height: 38px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem;
    transition: var(--transition);
    position: relative;
}
.bn-label {
    font-size: 0.6rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.3px;
    line-height: 1;
}
/* Badge merah di bottom nav */
.bn-badge {
    position: absolute;
    top: -2px; right: -2px;
    background: var(--accent-red);
    color: #fff;
    font-size: 0.55rem; font-weight: 800;
    min-width: 16px; height: 16px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 3px;
    border: 2px solid var(--bg-primary);
    animation: pulse-badge 1.5s infinite;
}
/* Tombol tengah (nurse call) — lebih besar & menonjol */
.bn-item.bn-center .bn-icon-wrap {
    width: 48px; height: 48px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--accent-red), #dc2626);
    box-shadow: 0 4px 16px rgba(239,68,68,0.4);
    font-size: 1.3rem;
}
.bn-item.bn-center.active .bn-icon-wrap,
.bn-item.bn-center:hover .bn-icon-wrap {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    box-shadow: 0 6px 20px rgba(239,68,68,0.5);
}
.bn-item.bn-center { color: #f87171; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
    overflow: hidden;
}
.card-header {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.5rem;
}
.card-header h3 { font-size: 0.875rem; font-weight: 600; }
.card-body { padding: 1rem; }

/* ============================================================
   STAT CARDS (KPI)
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex; align-items: center; gap: 0.875rem;
    transition: var(--transition);
    position: relative; overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 2px;
}
.stat-card.blue::before   { background: linear-gradient(90deg, var(--accent-blue), var(--accent-indigo)); }
.stat-card.green::before  { background: linear-gradient(90deg, var(--accent-green), #16a34a); }
.stat-card.yellow::before { background: linear-gradient(90deg, var(--accent-yellow), var(--accent-orange)); }
.stat-card.red::before    { background: linear-gradient(90deg, var(--accent-red), #dc2626); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-icon {
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; flex-shrink: 0;
}
.stat-card.blue   .stat-icon { background: rgba(56,189,248,0.15); }
.stat-card.green  .stat-icon { background: rgba(34,197,94,0.15); }
.stat-card.yellow .stat-icon { background: rgba(245,158,11,0.15); }
.stat-card.red    .stat-icon { background: rgba(239,68,68,0.15); }

.stat-info .stat-value {
    font-size: 1.6rem; font-weight: 800;
    line-height: 1; color: var(--text-primary);
}
.stat-info .stat-label { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ============================================================
   BADGE STATUS
   ============================================================ */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 9px; border-radius: 20px;
    font-size: 0.7rem; font-weight: 600;
    white-space: nowrap;
}
.badge-normal    { background: rgba(34,197,94,0.15);  color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.badge-warning   { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
.badge-kritis    { background: rgba(239,68,68,0.15);  color: #f87171; border: 1px solid rgba(239,68,68,0.3); animation: pulse-red 1s infinite; }
.badge-habis     { background: rgba(100,116,139,0.15);color: #94a3b8; border: 1px solid rgba(100,116,139,0.3); }
.badge-tersumbat { background: rgba(249,115,22,0.15); color: #fb923c; border: 1px solid rgba(249,115,22,0.3); }
.badge-online    { background: rgba(34,197,94,0.15);  color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.badge-offline   { background: rgba(100,116,139,0.15);color: #94a3b8; border: 1px solid rgba(100,116,139,0.3); }

@keyframes pulse-red {
    0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
    50%      { box-shadow: 0 0 0 4px rgba(239,68,68,0); }
}

/* ============================================================
   PROGRESS BAR INFUS
   ============================================================ */
.infus-bar-wrap { margin-top: 0.4rem; }
.infus-bar-track {
    height: 6px; background: rgba(255,255,255,0.08);
    border-radius: 10px; overflow: hidden;
}
.infus-bar-fill {
    height: 100%; border-radius: 10px;
    transition: width 0.5s ease;
}
.infus-bar-fill.normal  { background: linear-gradient(90deg, #22c55e, #4ade80); }
.infus-bar-fill.warning { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.infus-bar-fill.kritis  { background: linear-gradient(90deg, #ef4444, #f87171); animation: pulse-bar 1s infinite; }
.infus-bar-fill.habis   { background: #475569; }
@keyframes pulse-bar { 0%,100%{opacity:1} 50%{opacity:0.5} }

/* ============================================================
   TABEL — Responsive dengan horizontal scroll
   ============================================================ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
thead th {
    padding: 0.65rem 0.875rem;
    text-align: left;
    font-size: 0.68rem; font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: rgba(255,255,255,0.02);
}
tbody td {
    padding: 0.75rem 0.875rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 0.82rem;
    vertical-align: middle;
}
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody tr:last-child td { border-bottom: none; }
tbody tr.row-kritis  { background: rgba(239,68,68,0.05); }
tbody tr.row-warning { background: rgba(245,158,11,0.04); }

/* ============================================================
   NURSE CALL ALERT
   ============================================================ */
.nurse-call-alert {
    background: linear-gradient(135deg, rgba(239,68,68,0.15), rgba(239,68,68,0.05));
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: var(--radius);
    padding: 0.875rem 1rem;
    display: flex; align-items: center; gap: 0.875rem;
    margin-bottom: 0.875rem;
    animation: alert-pulse 2s infinite;
}
@keyframes alert-pulse {
    0%,100% { border-color: rgba(239,68,68,0.3); }
    50%      { border-color: rgba(239,68,68,0.7); box-shadow: 0 0 20px rgba(239,68,68,0.2); }
}
.nurse-call-alert .alert-icon { font-size: 1.4rem; flex-shrink: 0; }
.nurse-call-alert .alert-text { flex: 1; min-width: 0; }
.nurse-call-alert .alert-text h4 { font-size: 0.85rem; font-weight: 700; color: #f87171; }
.nurse-call-alert .alert-text p  { font-size: 0.75rem; color: var(--text-secondary); }
.nurse-call-alert .alert-actions { flex-shrink: 0; }

/* ============================================================
   TOMBOL
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem; font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer; border: none;
    transition: var(--transition); text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    color: #fff;
    box-shadow: 0 2px 10px rgba(56,189,248,0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(56,189,248,0.4); }
.btn-success { background: rgba(34,197,94,0.15); color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.btn-success:hover { background: rgba(34,197,94,0.25); }
.btn-danger  { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover  { background: rgba(239,68,68,0.25); }
.btn-ghost   { background: var(--bg-glass); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover   { background: rgba(255,255,255,0.1); color: var(--text-primary); }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.72rem; }

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: 0.75rem; font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.65rem 0.875rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
    /* Cegah zoom di iOS saat focus */
    font-size: max(16px, 0.875rem);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    background: rgba(56,189,248,0.05);
    box-shadow: 0 0 0 3px rgba(56,189,248,0.1);
}
.form-select option { background: var(--bg-secondary); }

/* ============================================================
   GRID LAYOUT
   ============================================================ */
.grid-2    { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3    { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }

/* ============================================================
   WARD / BED CARDS
   ============================================================ */
.bed-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    transition: var(--transition);
    position: relative; overflow: hidden;
}
.bed-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.bed-card.status-kritis  { border-color: rgba(239,68,68,0.4); animation: alert-pulse 2s infinite; }
.bed-card.status-warning { border-color: rgba(245,158,11,0.3); }
.bed-card.nurse-active   { border-color: rgba(239,68,68,0.5); box-shadow: 0 0 20px rgba(239,68,68,0.2); }

.bed-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.65rem; }
.bed-number { font-size: 0.68rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.bed-patient-name { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); margin-bottom: 0.2rem; }
.bed-diagnosa { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 0.65rem; }
.bed-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 0.65rem; }
.metric-item { text-align: center; }
.metric-value { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.metric-label { font-size: 0.62rem; color: var(--text-muted); text-transform: uppercase; }
.nurse-call-indicator {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.4rem 0.65rem;
    background: rgba(239,68,68,0.15);
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: 8px;
    font-size: 0.72rem; font-weight: 600; color: #f87171;
    animation: pulse-red 1s infinite;
}

/* ============================================================
   MODAL — Slide up di mobile
   ============================================================ */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex; align-items: flex-end; justify-content: center;
    padding: 0;
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%; max-width: 100%;
    max-height: 92vh; overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    /* Handle bar */
    padding-top: 0;
}
.modal-overlay.open .modal { transform: translateY(0); }

/* Handle bar di atas modal */
.modal::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    margin: 0.75rem auto 0;
}
.modal-header {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 0.95rem; font-weight: 700; }
.modal-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 1.2rem; cursor: pointer; transition: var(--transition);
    padding: 0.25rem;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 1rem 1.25rem; }
.modal-footer {
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 0.5rem;
    /* Ruang untuk safe area iPhone */
    padding-bottom: calc(0.875rem + env(safe-area-inset-bottom));
}

/* ============================================================
   TOAST NOTIFIKASI
   ============================================================ */
#toast-container {
    position: fixed; bottom: 1.5rem; right: 1rem;
    z-index: 999; display: flex; flex-direction: column; gap: 0.5rem;
    pointer-events: none;
}
.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    display: flex; align-items: center; gap: 0.75rem;
    min-width: 240px; max-width: 320px;
    box-shadow: var(--shadow-lg);
    animation: slide-in 0.3s ease;
    pointer-events: all;
}
.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error   { border-left: 3px solid var(--accent-red); }
.toast.warning { border-left: 3px solid var(--accent-yellow); }
.toast-msg { font-size: 0.82rem; flex: 1; }
@keyframes slide-in {
    from { transform: translateX(110%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* ============================================================
   RESPONSIVE — Mobile First
   ============================================================ */

/* ---- MOBILE (< 768px) ---- */
@media (max-width: 767px) {

    /* Sembunyikan sidebar, tampilkan bottom nav */
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .main-content { margin-left: 0; }

    /* Tampilkan hamburger di topbar */
    .topbar-menu-btn { display: flex; }

    /* Tampilkan bottom navigation */
    .bottom-nav { display: block; }

    /* Tambah padding bawah agar konten tidak tertutup bottom nav */
    .page-content {
        padding: 1rem;
        padding-bottom: calc(var(--bottom-nav-h) + 1rem + env(safe-area-inset-bottom));
    }

    /* Toast naik di atas bottom nav */
    #toast-container {
        bottom: calc(var(--bottom-nav-h) + 0.75rem + env(safe-area-inset-bottom));
        right: 0.75rem;
    }

    /* Stats 2 kolom di mobile */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.65rem; }

    /* Grid jadi 1 kolom */
    .grid-2, .grid-3 { grid-template-columns: 1fr; }

    /* Stat card lebih compact */
    .stat-card { padding: 0.875rem; gap: 0.75rem; }
    .stat-icon { width: 40px; height: 40px; font-size: 1.1rem; border-radius: 10px; }
    .stat-info .stat-value { font-size: 1.4rem; }

    /* Topbar lebih compact */
    .topbar { padding: 0 0.875rem; }
    .topbar-title h1 { font-size: 0.9rem; }
    .topbar-title p  { display: none; }

    /* Nurse call alert stack vertikal */
    .nurse-call-alert { flex-wrap: wrap; gap: 0.5rem; }
    .nurse-call-alert .alert-actions { width: 100%; }
    .nurse-call-alert .alert-actions .btn { width: 100%; justify-content: center; }

    /* Ward grid 1 kolom */
    .grid-auto { grid-template-columns: 1fr; }

    /* Modal full width */
    .modal { max-width: 100%; border-radius: var(--radius) var(--radius) 0 0; }

    /* Sembunyikan kolom tabel yang tidak penting */
    .hide-mobile { display: none !important; }

    /* Card header wrap */
    .card-header { flex-wrap: wrap; gap: 0.5rem; }
}

/* ---- TABLET (768px - 1023px) ---- */
@media (min-width: 768px) and (max-width: 1023px) {
    :root { --sidebar-w: 220px; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .page-content { padding: 1.25rem; }

    /* Modal center di tablet */
    .modal-overlay { align-items: center; padding: 1rem; }
    .modal {
        border-radius: var(--radius);
        max-width: 520px;
        transform: scale(0.95);
    }
    .modal-overlay.open .modal { transform: scale(1); }
    .modal::before { display: none; }
}

/* ---- DESKTOP (>= 1024px) ---- */
@media (min-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); }

    /* Modal center di desktop */
    .modal-overlay { align-items: center; padding: 1rem; }
    .modal {
        border-radius: var(--radius);
        max-width: 520px;
        transform: scale(0.95);
    }
    .modal-overlay.open .modal { transform: scale(1); }
    .modal::before { display: none; }
}

/* ---- LARGE DESKTOP (>= 1280px) ---- */
@media (min-width: 1280px) {
    .page-content { padding: 1.5rem; }
    .grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

/* ============================================================
   SCROLLBAR CUSTOM
   ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ============================================================
   UTILITIES
   ============================================================ */
.text-muted    { color: var(--text-muted); }
.text-success  { color: var(--accent-green); }
.text-warning  { color: var(--accent-yellow); }
.text-danger   { color: var(--accent-red); }
.text-info     { color: var(--accent-blue); }
.text-sm       { font-size: 0.8rem; }
.text-xs       { font-size: 0.7rem; }
.fw-bold       { font-weight: 700; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.w-full { width: 100%; }

/* ============================================================
   MOBILE POLISH EXTRAS
   ============================================================ */

/* Hapus highlight biru saat tap di mobile */
a, button { -webkit-tap-highlight-color: transparent; }

/* Smooth scroll di iOS */
.sidebar, .table-wrap, .modal { -webkit-overflow-scrolling: touch; }

/* Active state tombol di mobile lebih responsif */
.btn:active, .bn-item:active, .nav-item:active {
    opacity: 0.75;
    transform: scale(0.97);
}

/* Stat card di mobile — lebih compact */
@media (max-width: 380px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .stat-card { padding: 0.75rem; gap: 0.6rem; }
    .stat-icon { width: 36px; height: 36px; font-size: 1rem; }
    .stat-info .stat-value { font-size: 1.25rem; }
    .stat-info .stat-label { font-size: 0.65rem; }
    .page-content { padding: 0.75rem; }
    .topbar { padding: 0 0.75rem; }
}

/* Bottom nav safe area untuk iPhone X+ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
    }
}

/* Animasi masuk bottom nav item saat halaman load */
@media (max-width: 767px) {
    .bn-item {
        animation: bn-pop 0.4s ease backwards;
    }
    .bn-item:nth-child(1) { animation-delay: 0.05s; }
    .bn-item:nth-child(2) { animation-delay: 0.10s; }
    .bn-item:nth-child(3) { animation-delay: 0.15s; }
    .bn-item:nth-child(4) { animation-delay: 0.20s; }
    .bn-item:nth-child(5) { animation-delay: 0.25s; }
}
@keyframes bn-pop {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Ripple effect saat tap bottom nav */
.bn-item .bn-icon-wrap {
    overflow: hidden;
    position: relative;
}
.bn-item .bn-icon-wrap::after {
    content: '';
    position: absolute; inset: 0;
    background: rgba(255,255,255,0.15);
    border-radius: inherit;
    opacity: 0;
    transform: scale(0);
    transition: transform 0.3s, opacity 0.3s;
}
.bn-item:active .bn-icon-wrap::after {
    opacity: 1;
    transform: scale(1);
    transition: none;
}

/* Tabel mobile — kolom lebih rapat */
@media (max-width: 767px) {
    thead th { padding: 0.5rem 0.65rem; font-size: 0.62rem; }
    tbody td  { padding: 0.6rem 0.65rem; font-size: 0.78rem; }
}

/* Form filter riwayat — stack di mobile */
@media (max-width: 767px) {
    .filter-form-row {
        flex-direction: column !important;
    }
    .filter-form-row .form-group {
        min-width: unset !important;
        flex: unset !important;
        width: 100%;
    }
}

/* Nurse call alert di mobile */
@media (max-width: 767px) {
    .nurse-call-alert {
        padding: 0.75rem;
    }
}

/* Ward grid di mobile — 1 kolom penuh */
@media (max-width: 767px) {
    .grid-auto {
        grid-template-columns: 1fr;
    }
    .bed-card { padding: 0.875rem; }
}
