/* RxEMR — Modern Hospital Operating System Stylesheet */
:root {
    --sidebar-width: 256px;
    --topbar-height: 60px;
    --bg-body: #f8fafc;
    --surface: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.85);
    --surface-border: #e2e8f0;
    --sidebar-bg: #0b0f19;
    --sidebar-hover: #171f30;
    --primary: #0284c7;
    --primary-light: #e0f2fe;
    --primary-glow: rgba(14, 165, 233, 0.2);
    --secondary-glow: rgba(99, 102, 241, 0.2);
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #0ea5e9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-dim: #94a3b8;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid rgba(255, 255, 255, 0.07);
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar .brand {
    padding: 1.15rem 1.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 100%);
}

.sidebar .brand .brand-icon-box {
    width: 36px;
    height: 36px;
    border-radius: 0.65rem;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.25), rgba(99, 102, 241, 0.3));
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #38bdf8;
    box-shadow: 0 0 15px rgba(14, 165, 233, 0.3);
}

.sidebar .brand h5 {
    color: #ffffff;
    margin: 0;
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.3px;
}

.sidebar .brand small {
    color: #38bdf8;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.sidebar .nav-section {
    padding: 1rem 1.25rem 0.35rem;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.35);
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.65);
    padding: 0.62rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 500;
    margin: 0.1rem 0.6rem;
    border-radius: 0.55rem;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    white-space: nowrap;
    text-decoration: none;
}

.sidebar .nav-link i {
    font-size: 1.05rem;
    width: 1.35rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.45);
    transition: color 0.2s ease, transform 0.2s ease;
}

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

.sidebar .nav-link:hover i {
    color: #38bdf8;
    transform: scale(1.1);
}

.sidebar .nav-link.active {
    color: #ffffff;
    font-weight: 600;
    background: linear-gradient(90deg, rgba(14, 165, 233, 0.2), rgba(99, 102, 241, 0.12));
    border: 1px solid rgba(14, 165, 233, 0.25);
    box-shadow: 0 0 15px rgba(14, 165, 233, 0.15);
}

.sidebar .nav-link.active i {
    color: #38bdf8;
}

/* ==================== TOPBAR ==================== */
.topbar {
    position: fixed;
    top: 0; left: var(--sidebar-width); right: 0;
    height: var(--topbar-height);
    background: var(--surface-glass);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--surface-border);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.02);
}

.topbar .page-title {
    font-weight: 700;
    font-size: 1rem;
    color: #0f172a;
    letter-spacing: -0.2px;
    margin: 0;
}

.topbar .search-bar .input-group {
    background: #f1f5f9;
    border-radius: 50px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.topbar .search-bar .input-group:focus-within {
    background: #ffffff;
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

.topbar .search-bar input {
    background: transparent;
    border: none;
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
}

.topbar .search-bar input:focus {
    box-shadow: none;
    outline: none;
}

.topbar .centre-selector .form-select {
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 50px;
    border-color: #e2e8f0;
    background-color: #f8fafc;
    padding: 0.35rem 0.85rem;
    cursor: pointer;
}

.topbar .user-info {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.topbar .user-info .user-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: #1e293b;
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    padding: 1.5rem;
    min-height: calc(100vh - var(--topbar-height));
}

/* ==================== STAT CARDS & METRIC TILES ==================== */
.stat-card {
    background: #ffffff;
    border-radius: 1rem;
    border: 1px solid var(--surface-border);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 4px 12px -2px rgba(15, 23, 42, 0.03);
    position: relative;
    overflow: hidden;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -4px rgba(15, 23, 42, 0.08);
}

.stat-card .stat-icon-wrapper {
    width: 46px;
    height: 46px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    margin-bottom: 0.75rem;
}

.stat-card .stat-value {
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.1;
    color: #0f172a;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-top: 0.25rem;
}

/* ==================== ANALYTICS CARDS ==================== */
.analytics-card {
    background: #ffffff;
    border-radius: 1rem;
    border: 1px solid var(--surface-border);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 4px 12px -2px rgba(15, 23, 42, 0.03);
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
}

.analytics-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px -4px rgba(15, 23, 42, 0.08);
}

.analytics-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, #0ea5e9, #6366f1);
}
.analytics-card.accent-emerald::after { background: linear-gradient(90deg, #10b981, #059669); }
.analytics-card.accent-amber::after { background: linear-gradient(90deg, #f59e0b, #d97706); }
.analytics-card.accent-rose::after { background: linear-gradient(90deg, #f43f5e, #e11d48); }
.analytics-card.accent-indigo::after { background: linear-gradient(90deg, #6366f1, #4f46e5); }

.analytics-num {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: #0f172a;
    line-height: 1.1;
}

.analytics-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.analytics-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 600;
}

/* ==================== TABLES ==================== */
.table-container {
    background: #ffffff;
    border-radius: 1rem;
    border: 1px solid var(--surface-border);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03), 0 4px 12px -2px rgba(15, 23, 42, 0.02);
}

.table-container .table-header {
    padding: 0.9rem 1.25rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.table-container .table-header h6 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.2px;
}

.table th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    font-weight: 700;
    background: #f8fafc;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--surface-border);
}

.table td {
    font-size: 0.85rem;
    vertical-align: middle;
    padding: 0.85rem 1rem;
    color: #1e293b;
    border-bottom: 1px solid #f1f5f9;
}

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

/* ==================== CARDS & FORMS ==================== */
.page-card {
    background: #ffffff;
    border-radius: 1rem;
    border: 1px solid var(--surface-border);
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
}

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

.form-control, .form-select {
    font-size: 0.88rem;
    border-radius: 0.65rem;
    border: 1px solid #cbd5e1;
    padding: 0.55rem 0.85rem;
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

/* ==================== HIGH-TECH MODAL POP & BACKDROP ==================== */
.modal-backdrop {
    background-color: #0f172a;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.show {
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    opacity: 0.65;
}

.modal.fade .modal-dialog {
    transform: scale(0.88) translateY(30px);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease-out;
}

.modal.show .modal-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal-content {
    border-radius: 1.25rem;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 25px 65px -15px rgba(15, 23, 42, 0.35), 0 0 30px rgba(13, 110, 253, 0.12);
    overflow: hidden;
    background: #ffffff;
}

.modal-header {
    border-bottom: 1px solid #f1f5f9;
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
    padding: 1.15rem 1.4rem;
}

.modal-header .modal-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: #0f172a;
    letter-spacing: -0.2px;
}

.modal-footer {
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
    padding: 0.95rem 1.4rem;
}

/* ==================== STATUS PILLS & BADGES ==================== */
.status-badge, .status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25em 0.7em;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
    display: inline-block;
}

/* ==================== BUTTONS ==================== */
.btn {
    border-radius: 0.65rem;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    font-size: 0.88rem;
    padding: 0.5rem 1rem;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
}

.btn:active {
    transform: translateY(0);
}

.btn-sm {
    border-radius: 0.5rem;
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
}

.btn-primary {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    border-color: #0284c7;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0369a1, #075985);
    border-color: #0369a1;
    box-shadow: 0 4px 16px rgba(2, 132, 199, 0.45);
}

/* ==================== LEAN SMS / MESSAGING CONSOLE ==================== */
.sms-console-wrap {
    background: #ffffff;
    border-radius: 1.25rem;
    border: 1px solid var(--surface-border);
    overflow: hidden;
    box-shadow: 0 8px 30px -4px rgba(15, 23, 42, 0.06);
}

.sms-header {
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: #ffffff;
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sms-bubble {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    font-size: 0.88rem;
    line-height: 1.4;
    margin-bottom: 0.75rem;
    position: relative;
}

.sms-bubble.sent {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: #ffffff;
    margin-left: auto;
    border-bottom-right-radius: 0.25rem;
}

.sms-bubble.received {
    background: #f1f5f9;
    color: #0f172a;
    margin-right: auto;
    border-bottom-left-radius: 0.25rem;
    border: 1px solid #e2e8f0;
}

.sms-timestamp {
    font-size: 0.68rem;
    opacity: 0.75;
    margin-top: 0.25rem;
    display: block;
}

.sms-chip-recipient {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 50px;
    padding: 0.25rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
}

/* ==================== DX ENTERPRISE / DIAGNOSTICS ==================== */
.dx-card {
    background: #ffffff;
    border: 1px solid var(--surface-border);
    border-radius: 1rem;
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.04);
    padding: 1.25rem;
    transition: all 0.2s ease;
}

.dx-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 8px 25px rgba(15, 23, 42, 0.08);
}

.dx-status-flag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.72rem;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}
.dx-status-flag.normal { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.dx-status-flag.critical { background: #ffe4e6; color: #be123c; border: 1px solid #fecdd3; animation: pulseRed 2s infinite alternate; }
.dx-status-flag.pending { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.dx-status-flag.processing { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }

@keyframes pulseRed {
    0% { box-shadow: 0 0 0 rgba(225, 29, 72, 0); }
    100% { box-shadow: 0 0 10px rgba(225, 29, 72, 0.35); }
}

/* LOADING & TOAST */
.page-loading { text-align: center; padding: 3rem; color: var(--text-muted); }
.page-loading .spinner-border { width: 2.75rem; height: 2.75rem; color: var(--primary); }
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; }

/* RESPONSIVE */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content, .topbar { margin-left: 0; }
    .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 999; }
    .topbar { padding: 0 0.85rem; }
    .topbar .page-title { font-size: 0.9rem; }
    .main-content { padding: 1rem 0.75rem; }
    .modal-dialog { margin: 0.75rem auto; }
}

@media (max-width: 480px) {
    .topbar .centre-selector { display: none; }
    .topbar .search-bar { display: none; }
}
