/* โครงสร้างดีไซน์ระบบสรุปเคส - ชมรมสุริยะอาสาพยาบาล */

/* CSS Variables */
:root {
    --font-primary: 'Sarabun', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-secondary: 'Inter', sans-serif;
    
    /* Light Theme (Default) */
    --bg-app: #f8fafc;
    --bg-sidebar: #0f172a;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --border-color: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-sidebar: #94a3b8;
    --text-sidebar-active: #ffffff;
    --text-sidebar-hover: #cbd5e1;
    
    /* Branding Colors (Suriya Sun & Emergency Medical) */
    --primary: #f97316; /* ส้มสุริยะ */
    --primary-hover: #ea580c;
    --primary-light: #ffedd5;
    
    --secondary: #2563eb; /* น้ำเงินพยาบาล */
    --secondary-hover: #1d4ed8;
    --secondary-light: #dbeafe;
    
    --success: #10b981; /* เขียวทั่วไป */
    --success-light: #d1fae5;
    --warning: #f59e0b; /* เหลืองเร่งด่วน */
    --warning-light: #fef3c7;
    --danger: #ef4444; /* แดงวิกฤต */
    --danger-light: #fee2e2;
    
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.02);
    --hover-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    
    --transition-speed: 0.25s;
}

/* Dark Theme Variables */
body.dark-theme {
    --bg-app: #090d16;
    --bg-sidebar: #0f172a;
    --bg-card: #131b2e;
    --bg-input: #1e293b;
    --border-color: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    
    --primary-light: #2c1a0e;
    --secondary-light: #172554;
    --success-light: #064e3b;
    --warning-light: #451a03;
    --danger-light: #4c0519;
    
    --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.03);
    --hover-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: var(--font-primary);
    background-color: var(--bg-app);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

input, select, textarea, button {
    font-family: var(--font-primary);
    font-size: 1rem;
    color: inherit;
}

/* Core Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    padding: 24px;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    transition: width var(--transition-speed);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    padding: 0 4px;
}

.brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #ef4444);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 10px rgba(249, 115, 22, 0.4);
}

.logo-icon {
    width: 24px;
    height: 24px;
    animation: spin 20s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

.brand-text h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: white;
    line-height: 1.2;
}

.brand-text span {
    font-size: 0.75rem;
    color: var(--text-sidebar);
    font-family: var(--font-secondary);
    letter-spacing: 0.5px;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

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

.menu-item i {
    width: 20px;
    height: 20px;
    transition: transform 0.2s ease;
}

.menu-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-sidebar-hover);
}

.menu-item:hover i {
    transform: translateX(2px);
}

.menu-item.active {
    background: linear-gradient(135deg, var(--primary), #f97316cc);
    color: var(--text-sidebar-active);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.2);
}

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

.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.1);
    background-color: transparent;
    cursor: pointer;
    color: var(--text-sidebar);
    font-weight: 500;
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
}

.version-tag {
    font-size: 0.75rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.3);
    font-family: var(--font-secondary);
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    margin-left: 280px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Topbar Header */
.topbar {
    height: 80px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    position: sticky;
    top: 0;
    z-index: 90;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.view-title-area h2 {
    font-size: 1.4rem;
    font-weight: 700;
}

.view-title-area p {
    font-size: 0.85rem;
    margin-top: 2px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    background-color: var(--bg-app);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    font-weight: 500;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: relative;
}

.pulse-dot.green {
    background-color: var(--success);
}

.pulse-dot.green::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--success);
    opacity: 0.6;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(2.5); opacity: 0; }
}

/* Views wrapper */
.view-content-wrapper {
    padding: 40px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.view-section {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Global Elements & Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    user-select: none;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 10px rgba(249, 115, 22, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(249, 115, 22, 0.3);
}

.btn-secondary {
    background-color: var(--secondary-light);
    color: var(--secondary);
}

.btn-secondary:hover {
    background-color: var(--secondary);
    color: white;
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-success:hover {
    background-color: #059669;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

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

.btn-danger.btn-outline:hover {
    background-color: var(--danger);
    color: white;
}

.btn-muted {
    background-color: var(--border-color);
    color: var(--text-main);
}

.btn-muted:hover {
    background-color: var(--text-muted);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: var(--border-radius-sm);
}

.btn-lg {
    padding: 12px 24px;
    font-size: 1.05rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 12px;
    background-color: var(--border-color);
    color: var(--text-muted);
}

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

.badge-red {
    background-color: var(--danger-light);
    color: var(--danger);
}

.badge-yellow {
    background-color: var(--warning-light);
    color: var(--warning);
}

.badge-green {
    background-color: var(--success-light);
    color: var(--success);
}

/* Cards & Utilities */
.card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    padding: 24px;
    margin-bottom: 24px;
    transition: background-color var(--transition-speed), border-color var(--transition-speed), box-shadow var(--transition-speed);
}

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

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.margin-top-sm { margin-top: 12px; }
.margin-top-md { margin-top: 20px; }
.margin-top-lg { margin-top: 32px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-semibold { font-weight: 600; }
.col-span-2 { grid-column: span 2; }

/* 1. Dashboard Styles */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.25s ease;
}

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

.stat-icon-wrapper {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon-wrapper i {
    width: 28px;
    height: 28px;
}

.total-cases .stat-icon-wrapper { background-color: var(--secondary-light); color: var(--secondary); }
.severity-red .stat-icon-wrapper { background-color: var(--danger-light); color: var(--danger); }
.severity-yellow .stat-icon-wrapper { background-color: var(--warning-light); color: var(--warning); }
.severity-green .stat-icon-wrapper { background-color: var(--success-light); color: var(--success); }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: var(--font-secondary);
    margin: 4px 0;
    line-height: 1;
}

.stat-change, .stat-percentage {
    font-size: 0.75rem;
    font-weight: 500;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 32px;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.dashboard-card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
}

.card-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

.card-header p {
    font-size: 0.8rem;
    margin-top: 2px;
}

.card-body {
    padding: 24px;
    flex-grow: 1;
}

.chart-wrapper {
    position: relative;
    height: 320px;
    width: 100%;
}

/* Recent Cases List style */
.recent-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background-color: var(--bg-app);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.recent-item:hover {
    border-color: var(--text-muted);
    cursor: pointer;
    transform: scale(1.01);
}

.recent-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.recent-badge-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
}

.recent-badge-icon.red { background-color: var(--danger); }
.recent-badge-icon.yellow { background-color: var(--warning); }
.recent-badge-icon.green { background-color: var(--success); }

.recent-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
}

.recent-info p {
    font-size: 0.75rem;
    margin-top: 2px;
}

.recent-right {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

/* 2. Form Styles (New Case / Responders) */
.case-form {
    display: flex;
    flex-direction: column;
    gap: 32px;
    max-width: 1000px;
    margin: 0 auto;
}

.form-section-card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    padding: 32px;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
    margin-bottom: 24px;
}

.section-title i {
    width: 24px;
    height: 24px;
    color: var(--primary);
}

.section-title h3 {
    font-size: 1.2rem;
    font-weight: 700;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.form-grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

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

.form-group label {
    font-size: 0.9rem;
    font-weight: 600;
}

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

input[type="text"],
input[type="number"],
input[type="tel"],
input[type="email"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-input);
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

/* Patient Form Card (Multiple item) */
.patient-form-card {
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 24px;
    position: relative;
    animation: slideDown 0.25s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}

.patient-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 20px;
}

.patient-title-num {
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--secondary);
}

.remove-patient-btn {
    background-color: transparent;
    border: none;
    color: var(--danger);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.remove-patient-btn:hover {
    text-decoration: underline;
}

.vital-signs-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

@media (max-width: 768px) {
    .vital-signs-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.vital-input-wrapper {
    position: relative;
}

.vital-input-wrapper input {
    padding-right: 48px;
}

.vital-unit {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    pointer-events: none;
}

/* Co-Responders Grid Selection */
.co-responders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-input);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 6px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.checkbox-label:hover {
    background-color: var(--border-color);
}

.checkbox-label input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    padding-top: 16px;
}

/* 3. History View & Search filter */
.filter-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.filter-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.filter-header i {
    width: 18px;
    height: 18px;
    color: var(--primary);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.filter-footer {
    display: flex;
    justify-content: flex-end;
}

/* Data Table Style */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.table-title {
    font-size: 1.15rem;
    font-weight: 700;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

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

.data-table th, .data-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-weight: 700;
    font-size: 0.9rem;
    background-color: var(--bg-app);
    color: var(--text-muted);
}

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

.data-table tbody tr:hover {
    background-color: rgba(249, 115, 22, 0.02);
}

.action-buttons-cell {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    stroke-width: 1.5;
}

/* 4. Volunteer View layout (Form on Top, List below) */
.volunteers-layout-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.volunteer-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 8px;
}

.volunteer-form-element {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Modal detail styling */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease-out;
}

.modal-backdrop.active {
    display: flex;
}

.modal-container {
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    background-color: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: scaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleUp {
    from { transform: scale(0.95) translateY(10px); }
    to { transform: scale(1) translateY(0); }
}

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

.modal-title-area {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.severity-badge-pill {
    align-self: flex-start;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 20px;
    text-transform: uppercase;
}

.severity-badge-pill.red { background-color: var(--danger-light); color: var(--danger); border: 1px solid var(--danger); }
.severity-badge-pill.yellow { background-color: var(--warning-light); color: var(--warning); border: 1px solid var(--warning); }
.severity-badge-pill.green { background-color: var(--success-light); color: var(--success); border: 1px solid var(--success); }

.modal-header h3 {
    font-size: 1.3rem;
    font-weight: 700;
}

.close-btn {
    background-color: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.close-btn:hover {
    background-color: var(--border-color);
    color: var(--text-main);
}

.modal-body {
    padding: 32px;
    overflow-y: auto;
    flex-grow: 1;
}

.modal-footer {
    padding: 20px 32px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-app);
}

.modal-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 16px;
    margin-top: 24px;
    color: var(--secondary);
}

.modal-section-title i {
    width: 20px;
    height: 20px;
}

.modal-section-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

@media (max-width: 768px) {
    .modal-section-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.detail-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.detail-value {
    font-size: 0.95rem;
}

/* Patient Modal Detail Card */
.modal-patient-card {
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 16px;
}

.modal-patient-header {
    font-weight: 700;
    font-size: 0.95rem;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 12px;
    color: var(--text-main);
}

/* Vital Signs Grid View */
.vital-signs-table {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 12px 0;
    background-color: var(--bg-card);
    padding: 12px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
}

.vital-sign-indicator {
    flex: 1;
    min-width: 100px;
    text-align: center;
    padding: 6px;
    border-right: 1px solid var(--border-color);
}

.vital-sign-indicator:last-child {
    border-right: none;
}

.vital-sign-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 2px;
}

.vital-sign-value {
    font-family: var(--font-secondary);
    font-size: 1rem;
    font-weight: 700;
}

.vital-sign-value.abnormal {
    color: var(--danger);
}

.notes-content-box {
    background-color: var(--bg-app);
    padding: 16px;
    border-radius: var(--border-radius-sm);
    border-left: 4px solid var(--primary);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* PRINT ONLY HIDDEN CONTENT */
.print-header, .print-signatures {
    display: none;
}

/* Print CSS Stylesheet */
@media print {
    @page {
        size: A4;
        margin: 10mm 12mm;
    }

    body {
        background-color: white !important;
        color: black !important;
        font-size: 10pt !important;
        line-height: 1.25 !important;
    }
    
    .sidebar, .topbar, .modal-footer, .close-btn, .topbar-actions, #case-details-modal .modal-header button {
        display: none !important;
    }
    
    .app-container {
        display: block !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    
    .modal-backdrop {
        position: relative !important;
        background-color: transparent !important;
        backdrop-filter: none !important;
        z-index: auto !important;
        display: block !important;
        padding: 0 !important;
    }
    
    .modal-container {
        box-shadow: none !important;
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
        display: block !important;
        border: none !important;
    }
    
    .modal-body {
        padding: 0 !important;
        overflow: visible !important;
    }

    .modal-header {
        border-bottom: 2px solid black !important;
        padding: 6px 0 !important;
    }

    .modal-header h3 {
        font-size: 14pt !important;
    }
    
    /* Show Print Header */
    .print-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        border-bottom: 2px solid #000;
        padding-bottom: 8px !important;
        margin-bottom: 12px !important;
    }

    .print-logo-section {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .print-logo-img {
        width: 36px;
        height: 36px;
        object-fit: contain;
    }

    .print-logo-section h2 {
        font-size: 14pt;
        font-weight: 700;
    }

    .print-logo-section p {
        font-size: 8.5pt;
    }

    .print-meta-section {
        text-align: right;
        font-size: 8.5pt;
    }
    
    /* Layout styling for prints */
    .modal-section-grid {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        border: 1px solid #000 !important;
        margin-bottom: 10px !important;
    }

    .detail-block {
        border-right: 1px solid #000;
        border-bottom: 1px solid #000;
        padding: 5px 8px !important;
    }
    
    .detail-block:nth-child(4n) {
        border-right: none;
    }

    .detail-label {
        font-size: 7.5pt !important;
        color: #333 !important;
        text-transform: uppercase;
    }

    .detail-value {
        font-size: 9.5pt !important;
        font-weight: bold !important;
    }

    .modal-section-title {
        color: black !important;
        border-bottom: 1.5px solid #000 !important;
        font-size: 10.5pt !important;
        margin-top: 14px !important;
        margin-bottom: 6px !important;
        font-weight: 700 !important;
    }

    .modal-section-title i {
        display: none !important;
    }

    .modal-patient-card {
        border: 1px solid #000 !important;
        background-color: white !important;
        margin-bottom: 10px !important;
        padding: 8px !important;
        page-break-inside: avoid;
    }

    .modal-patient-header {
        border-bottom: 1px solid #000 !important;
        font-size: 9.5pt !important;
        font-weight: bold !important;
        padding-bottom: 4px !important;
        margin-bottom: 6px !important;
    }

    .vital-signs-table {
        border: 1px solid #000 !important;
        background-color: white !important;
    }

    .vital-sign-indicator {
        border-right: 1px solid #000 !important;
    }

    .vital-sign-value {
        font-size: 9pt !important;
    }

    .vital-sign-value.abnormal {
        color: black !important;
        text-decoration: underline !important;
    }

    .notes-content-box {
        background-color: white !important;
        border: 1px solid #000 !important;
        border-left: 4px solid #000 !important;
        padding: 8px !important;
        font-size: 9pt !important;
    }
    
    /* Signatures block for physical copies */
    .print-signatures {
        display: flex !important;
        justify-content: space-between;
        margin-top: 25px !important;
        page-break-inside: avoid;
    }

    .sig-block {
        width: 45%;
        text-align: center;
        font-size: 9pt;
    }

    .sig-label {
        margin-bottom: 25px !important;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .sidebar {
        width: 80px;
        padding: 16px 8px;
    }
    
    .sidebar-brand .brand-text, .menu-item span, .theme-toggle-btn span {
        display: none;
    }
    
    .sidebar-brand {
        justify-content: center;
        margin-bottom: 24px;
    }

    .menu-item {
        justify-content: center;
        padding: 12px;
    }

    .main-content {
        margin-left: 80px;
    }

    .topbar {
        padding: 0 20px;
    }

    .view-content-wrapper {
        padding: 20px;
    }
}

/* ==========================================
   7. Login / Register Overlay Styles
   ========================================== */
.login-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #090d16 0%, #1e293b 100%);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 9999;
    padding: 40px 20px;
    overflow-y: auto;
    backdrop-filter: blur(8px);
}

.login-card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    padding: 40px;
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin: auto;
    animation: scaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}

.login-logo {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), #ef4444);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.logo-icon-spin {
    width: 28px;
    height: 28px;
    animation: spin 20s linear infinite;
}

.login-brand-text h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.3;
}

.login-brand-text p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.login-tabs {
    display: flex;
    background-color: var(--bg-app);
    border-radius: var(--border-radius-sm);
    padding: 4px;
    border: 1px solid var(--border-color);
}

.login-tab {
    flex: 1;
    background: none;
    border: none;
    padding: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.login-tab:hover {
    color: var(--text-main);
}

.login-tab.active {
    background-color: var(--bg-card);
    color: var(--primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.login-tab-content {
    display: none;
    animation: fadeIn 0.25s ease-in-out;
}

.login-tab-content.active {
    display: block;
}

.login-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin: 16px 0;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px dashed var(--border-color);
}

.login-divider:not(:empty)::before {
    margin-right: .5em;
}

.login-divider:not(:empty)::after {
    margin-left: .5em;
}

/* ==========================================
   8. Quick Handouts Log Styles
   ========================================== */
.handouts-counter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
}

.handout-counter-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.handout-icon-box {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.handout-icon-box.ammonia-color {
    background: linear-gradient(135deg, #0ea5e9, #38bdf8);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.2);
}

.handout-icon-box.medicine-color {
    background: linear-gradient(135deg, #a855f7, #c084fc);
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.2);
}

.handout-icon-box.wound-color {
    background: linear-gradient(135deg, #f97316, #fb923c);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.2);
}

.handout-icon-box.cramp-color {
    background: linear-gradient(135deg, #10b981, #34d399);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.handout-icon-box i, .handout-icon-box svg {
    width: 28px;
    height: 28px;
}

.handout-details h4 {
    font-size: 1.1rem;
    font-weight: 700;
}

.handout-details p {
    font-size: 0.8rem;
    margin-top: 4px;
}

.counter-control-wrapper {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 8px;
}

.btn-counter {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-size: 1.5rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    user-select: none;
}

.btn-counter:hover {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(1.05);
}

.btn-counter:active {
    transform: scale(0.95);
}

.counter-display-value {
    font-size: 2.2rem;
    font-weight: 800;
    font-family: var(--font-secondary);
    min-width: 60px;
    text-align: center;
}

/* ==========================================
   Notifications & Toast Alerts System
   ========================================== */
.notification-bell-container {
    position: relative;
    display: inline-block;
}

.noti-bell-btn {
    position: relative;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: var(--text-main);
    transition: all 0.2s ease;
    background-color: var(--bg-card);
}

.noti-bell-btn:hover {
    background-color: var(--border-color);
    color: var(--primary);
    transform: scale(1.05);
}

.noti-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 0 2px var(--bg-card);
}

.noti-dropdown-menu {
    position: absolute;
    right: 0;
    top: 48px;
    width: 340px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    z-index: 110;
    display: none;
    animation: fadeInSlide 0.2s ease-out;
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.noti-dropdown-menu.active {
    display: block;
}

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

.noti-dropdown-header span {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-main);
}

.clear-noti-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: color 0.2s;
}

.clear-noti-btn:hover {
    color: var(--danger);
}

.noti-dropdown-list {
    max-height: 280px;
    overflow-y: auto;
}

.noti-empty-state {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.noti-empty-state i {
    width: 24px;
    height: 24px;
    opacity: 0.5;
}

.noti-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
}

.noti-item:hover {
    background-color: var(--bg-app);
}

.noti-item:last-child {
    border-bottom: none;
}

.noti-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.noti-item-icon.info {
    background-color: var(--primary-light);
    color: var(--primary);
}

.noti-item-icon.success {
    background-color: var(--success-light);
    color: var(--success);
}

.noti-item-icon.warning {
    background-color: var(--warning-light);
    color: var(--warning);
}

.noti-item-body {
    flex: 1;
}

.noti-item-title {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-main);
    margin-bottom: 2px;
}

.noti-item-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.noti-item-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

/* Toast System styling */
#toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast-notification {
    background-color: var(--bg-card);
    border: 1px solid rgba(128, 128, 128, 0.2);
    border-left: 5px solid var(--primary);
    border-radius: var(--border-radius);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    padding: 14px 18px;
    width: 320px;
    display: flex;
    gap: 12px;
    pointer-events: auto;
    animation: toastSlideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transition: all 0.2s ease;
}

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

.toast-notification.fadeOut {
    opacity: 0;
    transform: translateX(120%) scale(0.9);
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.toast-notification.success {
    border-left-color: var(--success);
}
.toast-notification.success .toast-icon {
    color: var(--success);
}

.toast-notification.info {
    border-left-color: var(--primary);
}
.toast-notification.info .toast-icon {
    color: var(--primary);
}

.toast-notification.warning {
    border-left-color: var(--warning);
}
.toast-notification.warning .toast-icon {
    color: var(--warning);
}

.toast-notification.danger {
    border-left-color: var(--danger);
}
.toast-notification.danger .toast-icon {
    color: var(--danger);
}

.toast-body {
    flex: 1;
}

.toast-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-main);
    margin-bottom: 2px;
}

.toast-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    height: 18px;
    width: 18px;
}

.toast-close:hover {
    color: var(--danger);
}

/* Active dispatch calls styles */
.dispatch-ticket {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 14px 18px;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, border-color 0.2s;
}

.dispatch-ticket:hover {
    transform: translateY(-2px);
    border-color: var(--warning);
}

.dispatch-ticket-left {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: 1;
}

.dispatch-ticket-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--warning-light);
    color: var(--warning);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.dispatch-ticket-content {
    flex: 1;
}

.dispatch-ticket-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-main);
    margin-bottom: 4px;
}

.dispatch-ticket-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.dispatch-ticket-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.dispatch-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.dispatch-ticket-right {
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .dispatch-ticket {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .dispatch-ticket-right button {
        width: 100%;
    }
}

/* Mobile responsive toast banner style */
@media (max-width: 576px) {
    #toast-container {
        top: 12px;
        right: 12px;
        left: 12px;
        width: calc(100% - 24px);
    }
    .toast-notification {
        width: 100%;
    }
}
