/* Raymine Hospital EMR - Modern Medical Design System */

:root {
    --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    /* Color Palette */
    --bg-main: #f8fafc;
    --bg-sidebar: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-hover: #1e293b;
    
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: #e0f2fe;

    --secondary: #64748b;
    --success: #10b981;
    --success-light: #d1fae5;

    --emerald: #059669;
    --emerald-hover: #047857;
    --emerald-light: #ecfdf5;

    --purple: #8b5cf6;
    --purple-light: #f3e8ff;

    --amber: #f59e0b;
    --amber-light: #fef3c7;

    --danger: #ef4444;
    --danger-light: #fee2e2;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* App Layout Grid */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 24px;
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), #38bdf8);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.brand-text h2 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.hospital-sub {
    font-size: 11px;
    color: var(--sidebar-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 12px 4px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.nav-item i {
    font-size: 16px;
    width: 20px;
}

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

.nav-item.active {
    background: linear-gradient(90deg, rgba(2, 132, 199, 0.25), rgba(2, 132, 199, 0.05));
    color: #38bdf8;
    border-left: 3px solid #38bdf8;
    font-weight: 600;
}

.nav-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.badge {
    margin-left: auto;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.badge-active {
    background-color: rgba(56, 189, 248, 0.2);
    color: #38bdf8;
}

.badge-upcoming {
    background-color: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.db-status {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: var(--radius-sm);
}

.db-title {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #f1f5f9;
}

.db-desc {
    display: block;
    font-size: 10px;
    color: #94a3b8;
}

.text-success { color: var(--success); }

.docs-link {
    color: #38bdf8;
    font-size: 12px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.docs-link:hover { text-decoration: underline; }

/* Main Content Area */
.main-content {
    flex-grow: 1;
    padding: 32px;
    overflow-y: auto;
}

/* Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.header-title h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.header-actions .btn {
    flex: 1 1 170px;
    justify-content: center;
    text-align: center;
}

/* Stat Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.bg-blue { background-color: var(--primary-light); color: var(--primary); }
.bg-teal { background-color: #cff4fc; color: #055160; }
.bg-purple { background-color: var(--purple-light); color: var(--purple); }
.bg-emerald { background-color: var(--emerald-light); color: var(--emerald); }

.stat-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

/* Toolbar & Filters */
.toolbar {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: var(--shadow-sm);
}

.search-box {
    position: relative;
    flex-grow: 1;
    max-width: 480px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
}

.search-box input {
    width: 100%;
    padding: 10px 38px 10px 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    background-color: #f8fafc;
    transition: all 0.2s;
}

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

.clear-search-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.form-select, .form-control {
    padding: 9px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background-color: #ffffff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 8px rgba(2, 132, 199, 0.3);
}

.btn-emerald {
    background-color: var(--emerald);
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(5, 150, 105, 0.2);
}

.btn-emerald:hover {
    background-color: var(--emerald-hover);
    box-shadow: 0 4px 8px rgba(5, 150, 105, 0.3);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background-color: var(--bg-main);
    color: var(--text-primary);
}

.btn-secondary {
    background-color: #e2e8f0;
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: #cbd5e1;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Data Table Card */
.table-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    background-color: #f1f5f9;
    padding: 14px 18px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 16px 18px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background-color 0.15s;
}

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

/* Patient & Visit Badges */
.patient-id-badge {
    font-family: monospace;
    font-weight: 700;
    background-color: #f1f5f9;
    color: var(--primary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid #cbd5e1;
}

.visit-code-badge {
    font-family: monospace;
    font-weight: 700;
    background-color: var(--emerald-light);
    color: var(--emerald);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid #a7f3d0;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
}

.tag-individual {
    background-color: var(--primary-light);
    color: var(--primary);
}

.tag-family {
    background-color: var(--purple-light);
    color: var(--purple);
}

.tag-hmo {
    background-color: var(--emerald-light);
    color: var(--emerald);
    border: 1px solid #a7f3d0;
}

.tag-selfpay {
    background-color: #f1f5f9;
    color: var(--text-muted);
}

.diagnosis-tag {
    display: inline-block;
    background-color: #fef3c7;
    color: #92400e;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    margin-right: 4px;
    margin-bottom: 4px;
}

/* Action buttons in row */
.action-btns {
    display: flex;
    gap: 8px;
}

/* Empty State */
.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    color: #cbd5e1;
    margin-bottom: 16px;
}

.empty-state h3 {
    color: var(--text-primary);
    margin-bottom: 6px;
}

/* Family Grid Cards */
.family-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.family-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.family-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 14px;
}

.family-card-title h3 {
    font-size: 16px;
    font-weight: 700;
}

.member-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.member-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: #f8fafc;
    border-radius: var(--radius-md);
    font-size: 13px;
}

/* Modal Scroll Lock Pattern */
body.modal-open {
    overflow: hidden !important;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    transition: opacity 0.25s, visibility 0.25s;
}

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

.modal-dialog {
    background-color: var(--card-bg);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 650px;
    max-height: min(90vh, calc(100vh - 40px));
    height: auto;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.25s ease;
    overflow: hidden;
}

.modal-dialog > form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.modal-backdrop.active .modal-dialog {
    transform: scale(1);
}

.modal-lg {
    max-width: 850px;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
}

.modal-close:hover {
    color: var(--text-primary);
    background-color: var(--bg-main);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    overscroll-behavior: contain;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background-color: #f8fafc;
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    flex-shrink: 0;
}

/* Form Styling */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.col-span-2 {
    grid-column: span 2;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.required {
    color: var(--danger);
}

.form-section-header {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 6px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.age-display-box, .bmi-display-box {
    background-color: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 9px 14px;
    font-size: 14px;
    font-weight: 700;
    color: var(--emerald);
}

.prefill-badge {
    font-size: 11px;
    background-color: var(--purple-light);
    color: var(--purple);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

/* Radio Card Selector */
.radio-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.radio-card {
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.radio-card input[type="radio"] {
    display: none;
}

.radio-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.radio-content i {
    font-size: 20px;
    color: var(--text-muted);
}

.radio-content strong {
    display: block;
    color: var(--text-primary);
}

.radio-content span {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
}

.radio-card:has(input[type="radio"]:checked) {
    border-color: var(--primary);
    background-color: var(--primary-light);
}

.radio-card:has(input[type="radio"]:checked) .radio-content i {
    color: var(--primary);
}

.family-options-panel {
    background-color: #f8fafc;
    border: 1px dashed #cbd5e1;
    padding: 16px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.divider-text {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    position: relative;
}

/* Detail View Layout */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.detail-card {
    background-color: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
}

.detail-card h4 {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px border-dashed #e2e8f0;
}

.detail-item span:first-child {
    color: var(--text-secondary);
}

.detail-item span:last-child {
    font-weight: 600;
    color: var(--text-primary);
}

/* Printable Consultation Note Styling */
.consultation-note-card {
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.hospital-branding h2 {
    font-size: 20px;
    color: var(--text-primary);
}

.note-vitals-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.note-vitals-table th, .note-vitals-table td {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    font-size: 13px;
    text-align: center;
}

.note-vitals-table th {
    background-color: #f8fafc;
    font-weight: 700;
    color: var(--text-muted);
}

.note-section {
    margin-bottom: 16px;
}

.note-section h4 {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    border-left: 3px solid var(--primary);
    padding-left: 8px;
}

.note-section p {
    font-size: 14px;
    color: var(--text-primary);
    white-space: pre-line;
    background-color: #f8fafc;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
}

.doctor-signature-box {
    margin-top: 30px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background-color: var(--text-primary);
    color: #ffffff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

.toast-success { background-color: #064e3b; border-left: 4px solid var(--success); }
.toast-error { background-color: #7f1d1d; border-left: 4px solid var(--danger); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.mt-3 { margin-top: 12px; }

@media print {
    .sidebar, .top-header, .stats-grid, .toolbar, .modal-header, .modal-footer, .toast-container {
        display: none !important;
    }
    .modal-backdrop {
        position: static !important;
        background: none !important;
        padding: 0 !important;
    }
    .modal-dialog {
        max-width: 100% !important;
        max-height: 100% !important;
        box-shadow: none !important;
        border: none !important;
    }
    .modal-body {
        padding: 0 !important;
        overflow: visible !important;
    }
}
.tag-danger {
    background-color: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.tag-muted {
    background-color: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}
.tag-warning {
    background-color: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}
.sub-tab-btn {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
}

.sub-tab-btn.active {
    color: var(--emerald);
    border-bottom-color: var(--emerald);
}

.stock-low {
    color: #dc2626;
    font-weight: 700;
}