/* Doctors Aid - Modern Medical Application Design */

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

/* Medical Application Color Palette */
:root {
    /* Primary Medical Colors */
    --medical-primary: #2E7D32;          /* Medical Green */
    --medical-primary-light: #4CAF50;    /* Light Green */
    --medical-primary-dark: #1B5E20;     /* Dark Green */
    
    /* Secondary Colors */
    --medical-secondary: #1976D2;        /* Medical Blue */
    --medical-secondary-light: #42A5F5;  /* Light Blue */
    --medical-accent: #FF6B35;           /* Orange Accent */
    
    /* Status Colors */
    --medical-success: #2E7D32;          /* Success Green */
    --medical-warning: #F57C00;          /* Warning Orange */
    --medical-danger: #D32F2F;           /* Danger Red */
    --medical-info: #1976D2;             /* Info Blue */
    
    /* Neutral Colors */
    --medical-white: #FFFFFF;
    --medical-gray-50: #FAFAFA;
    --medical-gray-100: #F5F5F5;
    --medical-gray-200: #EEEEEE;
    --medical-gray-300: #E0E0E0;
    --medical-gray-400: #BDBDBD;
    --medical-gray-500: #9E9E9E;
    --medical-gray-600: #757575;
    --medical-gray-700: #616161;
    --medical-gray-800: #424242;
    --medical-gray-900: #212121;
    
    /* Text Colors */
    --text-primary: #212121;
    --text-secondary: #757575;
    --text-disabled: #BDBDBD;
    --text-white: #FFFFFF;
    
    /* Background Colors */
    --bg-primary: #FAFAFA;
    --bg-secondary: #FFFFFF;
    --bg-elevated: #FFFFFF;
    --bg-overlay: rgba(0, 0, 0, 0.5);
    
    /* Border Colors */
    --border-light: #E0E0E0;
    --border-medium: #BDBDBD;
    --border-dark: #9E9E9E;
    
    /* Shadow Colors */
    --shadow-light: rgba(0, 0, 0, 0.08);
    --shadow-medium: rgba(0, 0, 0, 0.12);
    --shadow-heavy: rgba(0, 0, 0, 0.16);
    
    /* Typography */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-secondary: 'Roboto', sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    
    /* Font Sizes */
    --text-xs: 0.75rem;    /* 12px */
    --text-sm: 0.875rem;   /* 14px */
    --text-base: 1rem;     /* 16px */
    --text-lg: 1.125rem;   /* 18px */
    --text-xl: 1.25rem;    /* 20px */
    --text-2xl: 1.5rem;    /* 24px */
    --text-3xl: 1.875rem;  /* 30px */
    --text-4xl: 2.25rem;   /* 36px */
    
    /* Spacing */
    --space-1: 0.25rem;    /* 4px */
    --space-2: 0.5rem;     /* 8px */
    --space-3: 0.75rem;    /* 12px */
    --space-4: 1rem;       /* 16px */
    --space-5: 1.25rem;    /* 20px */
    --space-6: 1.5rem;     /* 24px */
    --space-8: 2rem;       /* 32px */
    --space-10: 2.5rem;    /* 40px */
    --space-12: 3rem;      /* 48px */
    --space-16: 4rem;      /* 64px */
    
    /* Border Radius */
    --radius-sm: 0.25rem;  /* 4px */
    --radius-md: 0.5rem;   /* 8px */
    --radius-lg: 0.75rem;  /* 12px */
    --radius-xl: 1rem;     /* 16px */
    --radius-2xl: 1.5rem;  /* 24px */
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-normal: 250ms ease-in-out;
    --transition-slow: 350ms ease-in-out;
    
    /* Z-Index */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1085;
    --z-modal: 1090;
    --z-popover: 1060;
    --z-tooltip: 1070;
}

/* Reset and Base Styles */
* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-primary);
    font-weight: 600;
    line-height: 1.2;
    margin: 0 0 var(--space-4) 0;
    color: var(--text-primary);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p {
    margin: 0 0 var(--space-4) 0;
    color: var(--text-secondary);
}

/* Auth / registration headers on dark bands: global body-copy grey must not win over white text */
.register-header,
.card-header-custom,
.login-header {
    color: var(--text-white);
}

.register-header :is(h1, h2, h3, h4, h5, h6, p),
.card-header-custom :is(h1, h2, h3, h4, h5, h6, p),
.login-header :is(h1, h2, h3, h4, h5, h6, p) {
    color: inherit;
}

.register-header p,
.card-header-custom p,
.login-header p {
    margin-top: var(--space-2);
    margin-bottom: 0;
    font-size: var(--text-sm);
    line-height: 1.5;
    opacity: 0.95;
}

/* Help text under form fields — darker than default muted for readability */
.form-text {
    color: var(--medical-gray-700);
}

/* Medical Application Layout */
.medical-app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.medical-header {
    background: var(--medical-white);
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 2px 4px var(--shadow-light);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-6);
    max-width: var(--content-max-width, 1400px);
    margin: 0 auto;
    flex-wrap: wrap;
    gap: var(--space-3);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex: 0 0 auto;
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-full);
    background: var(--medical-white);
    color: var(--medical-primary);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.sidebar-toggle i {
    font-size: var(--text-lg);
}

.sidebar-toggle:hover {
    background: var(--medical-primary);
    color: var(--medical-white);
    border-color: var(--medical-primary);
}

.medical-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--medical-primary);
    font-weight: 700;
    font-size: var(--text-xl);
    flex: 0 0 auto;
}

.medical-logo i {
    font-size: var(--text-2xl);
    margin-right: var(--space-3);
    color: var(--medical-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex: 1 1 320px;
    justify-content: flex-end;
}

@media (max-width: 992px) {
    .header-content {
        justify-content: center;
    }

    .medical-logo {
        justify-content: center;
    }

    .header-actions {
        width: 100%;
        flex: 1 1 100%;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: stretch;
    }

    .header-actions {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
    }

    .search-container {
        width: 100%;
    }

    .dropdown {
        width: 100%;
        display: flex;
        justify-content: flex-end;
    }
}

/* Sidebar */
.medical-sidebar {
    background: var(--medical-white);
    border-right: 1px solid var(--border-light);
    width: 280px;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: var(--z-fixed);
    overflow-y: auto;
    transition: transform var(--transition-normal);
}

.sidebar-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-light);
    background: linear-gradient(135deg, var(--medical-primary) 0%, var(--medical-primary-dark) 100%);
    color: var(--medical-white);
}

.sidebar-nav {
    padding: var(--space-4);
}

.nav-section {
    margin-bottom: var(--space-6);
}

.nav-section-title {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-3);
    padding: 0 var(--space-3);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-1);
    transition: all var(--transition-fast);
    font-weight: 500;
}

.nav-item:hover {
    background-color: var(--medical-gray-50);
    color: var(--medical-primary);
    transform: translateX(4px);
}

.nav-item.active {
    background-color: var(--medical-primary);
    color: var(--medical-white);
}

.nav-item i {
    width: 20px;
    margin-right: var(--space-3);
    font-size: var(--text-lg);
}

/* Main Content */
.medical-main {
    flex: 1;
    margin-left: 280px;
    padding: var(--space-6);
    background-color: var(--bg-primary);
    min-height: calc(100vh - 80px);
}

.main-container {
    max-width: var(--content-max-width, 1400px);
    margin: 0 auto;
}

/* Density: Compact reduces base font + paddings and relaxes the width cap so wide monitors get the
   space on data-dense screens. Custom properties are scoped to the app root so they cascade to all
   descendants without per-page work. */
.medical-app.density-compact {
    --text-base: 0.875rem;   /* 14px */
    --text-sm: 0.8125rem;    /* 13px */
    --text-lg: 1rem;         /* 16px */
    --space-4: 0.75rem;      /* 16px -> 12px */
    --space-6: 1rem;         /* 24px -> 16px */
    --content-max-width: none;
}

.medical-app.density-compact .table > :not(caption) > * > * {
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
}

.medical-app.density-compact .card-body {
    padding: var(--space-4);
}

/* Medical Cards */
.medical-card {
    background: var(--medical-white);
    border-radius: var(--radius-xl);
    box-shadow: 0 2px 8px var(--shadow-light);
    border: 1px solid var(--border-light);
    overflow: hidden;
    transition: all var(--transition-normal);
}

.medical-card:hover {
    box-shadow: 0 8px 25px var(--shadow-medium);
    transform: translateY(-2px);
}

.card-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-secondary);
}

.card-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.card-subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: var(--space-2) 0 0 0;
}

.card-body {
    padding: var(--space-6);
}

.card-footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border-light);
    background: var(--bg-secondary);
}

/* Medical Buttons */
.btn-medical {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-md);
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--text-sm);
    line-height: 1;
    gap: var(--space-2);
}

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

.btn-medical-primary:hover {
    background-color: var(--medical-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}

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

.btn-medical-secondary:hover {
    background-color: var(--medical-secondary-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.3);
}

.btn-medical-outline {
    background-color: transparent;
    color: var(--medical-primary);
    border: 2px solid var(--medical-primary);
}

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

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

.btn-medical-ghost:hover {
    background-color: var(--medical-gray-50);
    color: var(--medical-primary);
    border-color: var(--medical-primary);
}

/* Medical Forms */
.medical-form {
    background: var(--medical-white);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    box-shadow: 0 2px 8px var(--shadow-light);
}

.form-group {
    margin-bottom: var(--space-6);
}

.form-label {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
}

.form-control {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    transition: all var(--transition-fast);
    background-color: var(--medical-white);
}

.form-control:focus {
    outline: none;
    border-color: var(--medical-primary);
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}

.form-control:disabled {
    background-color: var(--medical-gray-50);
    color: var(--text-disabled);
    cursor: not-allowed;
}

/* Medical Tables */
.medical-table {
    width: 100%;
    background: var(--medical-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow-light);
}

.medical-table th {
    background-color: var(--medical-gray-50);
    padding: var(--space-4);
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    font-size: var(--text-sm);
}

.medical-table td {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.medical-table tr:hover {
    background-color: var(--medical-gray-50);
}

/* Medical Alerts */
.medical-alert {
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
    border-left: 4px solid;
    font-weight: 500;
}

.medical-alert-success {
    background-color: #E8F5E8;
    color: var(--medical-success);
    border-left-color: var(--medical-success);
}

.medical-alert-warning {
    background-color: #FFF3E0;
    color: var(--medical-warning);
    border-left-color: var(--medical-warning);
}

.medical-alert-danger {
    background-color: #FFEBEE;
    color: var(--medical-danger);
    border-left-color: var(--medical-danger);
}

.medical-alert-info {
    background-color: #E3F2FD;
    color: var(--medical-info);
    border-left-color: var(--medical-info);
}

/* Medical Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-6);
    margin-bottom: var(--space-8);
}

.dashboard-header {
    background: linear-gradient(135deg, var(--medical-primary) 0%, var(--medical-primary-dark) 100%);
    color: var(--medical-white);
    padding: var(--space-8);
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-8);
    position: relative;
    overflow: hidden;
}

.dashboard-header::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 200px;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50% 0 0 50%;
}

.dashboard-title {
    font-size: var(--text-3xl);
    font-weight: 700;
    margin-bottom: var(--space-2);
}

.dashboard-subtitle {
    font-size: var(--text-lg);
    opacity: 0.9;
    margin: 0;
}

/* Doctor dashboard header: high-contrast subtitle on primary gradient */
.dashboard-header .dashboard-subtitle {
    color: #f8fafc;
    opacity: 1;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

/* Clear (outline) on primary gradient — same contrast treatment as subtitle */
.dashboard-header .btn-medical-outline {
    color: #f8fafc;
    border-color: rgba(255, 255, 255, 0.9);
    background-color: rgba(255, 255, 255, 0.12);
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.dashboard-header .btn-medical-outline:hover,
.dashboard-header .btn-medical-outline:focus-visible {
    color: var(--medical-primary-dark);
    background-color: #f8fafc;
    border-color: #f8fafc;
    text-shadow: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Metric Cards */
.metric-card {
    background: var(--medical-white);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: 0 2px 8px var(--shadow-light);
    border: 1px solid var(--border-light);
    transition: all var(--transition-normal);
    height: 100%;
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px var(--shadow-medium);
}

.metric-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xl);
    color: var(--medical-white);
}

.metric-icon.primary { background-color: var(--medical-primary); }
.metric-icon.secondary { background-color: var(--medical-secondary); }
.metric-icon.success { background-color: var(--medical-success); }
.metric-icon.warning { background-color: var(--medical-warning); }
.metric-icon.danger { background-color: var(--medical-danger); }

.metric-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1;
}

.metric-label {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    margin: var(--space-2) 0 0 0;
}

.metric-change {
    color: var(--medical-success);
    font-size: var(--text-xs);
    margin-top: var(--space-2);
    font-weight: 500;
}

/* Doctor dashboard: compact clickable metric tiles */
.dashboard-metrics {
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

.metric-card-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.metric-card-link:hover,
.metric-card-link:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--shadow-medium);
    border-color: var(--medical-primary);
    color: inherit;
    text-decoration: none;
}

.metric-card-link:focus-visible {
    outline: 2px solid var(--medical-primary);
    outline-offset: 2px;
}

.dashboard-metrics .metric-icon {
    width: 2.25rem;
    height: 2.25rem;
    flex-shrink: 0;
    font-size: var(--text-base);
    margin: 0;
}

.dashboard-metrics .metric-body {
    flex: 1 1 auto;
    min-width: 0;
}

.dashboard-metrics .metric-value {
    font-size: var(--text-2xl);
    font-weight: 700;
    line-height: 1.1;
}

.dashboard-metrics .metric-label {
    font-size: var(--text-xs);
    margin-top: var(--space-1);
    line-height: 1.35;
}

@media (min-width: 992px) {
    .dashboard-metrics {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Dashboard: fixed bottom quick-action hot bar */
.dashboard-page {
    padding-bottom: 5.5rem;
}

.dashboard-appointments-card {
    margin-top: 1.5rem;
    margin-bottom: 1.75rem;
}

.dashboard-appointments-card .card-header {
    padding-bottom: 0.75rem;
}

.dashboard-appointments-card .card-body {
    padding-top: 0.5rem;
}

.dashboard-calendar-legend .badge {
    font-size: 0.7rem;
    font-weight: 600;
}

#dashboardAppointmentCalendar {
    --fc-border-color: var(--border-light);
    --fc-button-bg-color: var(--medical-primary);
    --fc-button-border-color: var(--medical-primary);
    --fc-button-hover-bg-color: var(--medical-primary-dark);
    --fc-button-hover-border-color: var(--medical-primary-dark);
    --fc-today-bg-color: rgba(13, 110, 253, 0.06);
}

#dashboardAppointmentCalendar .fc-toolbar-title {
    font-size: 1rem;
    font-weight: 600;
}

#dashboardAppointmentCalendar .fc-col-header-cell-cushion,
#dashboardAppointmentCalendar .fc-timegrid-slot-label-cushion {
    font-size: 0.75rem;
}

#dashboardAppointmentCalendar .fc-event {
    font-size: 0.75rem;
    border-radius: 0.35rem;
    cursor: pointer;
}

.dashboard-hotbar {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1040;
    width: 50vw;
    min-width: 16rem;
    max-width: 40rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: var(--medical-white);
    border: 1px solid var(--border-light);
    border-radius: 999px;
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.14), 0 2px 8px var(--shadow-light);
}

.dashboard-hotbar__action {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.85rem;
    border-radius: 999px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background var(--transition-fast), color var(--transition-fast),
        transform var(--transition-fast), box-shadow var(--transition-fast);
}

.dashboard-hotbar__action:hover {
    background: var(--medical-primary);
    border-color: var(--medical-primary);
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.25);
}

.dashboard-hotbar__action:hover i {
    color: #fff;
}

.dashboard-hotbar__action i {
    font-size: 0.95rem;
    color: var(--medical-primary);
    transition: color var(--transition-fast);
}

@media (max-width: 767.98px) {
    .dashboard-hotbar {
        width: calc(100vw - 2rem);
        min-width: 0;
        border-radius: var(--radius-xl);
        padding: 0.65rem 0.75rem;
    }

    .dashboard-hotbar__action {
        padding: 0.45rem 0.65rem;
        font-size: 0.75rem;
    }

    .dashboard-hotbar__action span {
        max-width: 5.5rem;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .medical-sidebar {
        transform: translateX(-100%);
    }
    
    .medical-main {
        margin-left: 0;
    }
    
    .sidebar-open .medical-sidebar {
        transform: translateX(0);
    }
}

@media (max-width: 768px) {
    .medical-main {
        padding: var(--space-4);
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
    
    .header-content {
        padding: var(--space-3) var(--space-4);
    }
    
    .medical-card {
        margin-bottom: var(--space-4);
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }

.p-0 { padding: 0; }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

.d-flex { display: flex; }
.d-grid { display: grid; }
.d-block { display: block; }
.d-none { display: none; }

.align-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }

.shadow { box-shadow: 0 2px 8px var(--shadow-light); }
.shadow-lg { box-shadow: 0 8px 25px var(--shadow-medium); }

/* Beta / release phase UI (see doctors-aid.release in application.yml) */
.app-release-badge {
    display: inline-block;
    margin-left: var(--space-2);
    padding: 0.15rem 0.5rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    vertical-align: middle;
    color: #5d4037;
    background: #fff3e0;
    border: 1px solid #ffb74d;
    border-radius: var(--radius-md);
    line-height: 1.2;
}
.app-release-badge--sidebar {
    margin-left: 0;
    margin-bottom: var(--space-2);
}
.app-release-badge--compact {
    margin-left: var(--space-2);
    font-size: 0.6rem;
}
.app-release-banner {
    background: linear-gradient(90deg, #fff8e1 0%, #fff3e0 100%);
    border-bottom: 1px solid #ffcc80;
    color: #5d4037;
    font-size: var(--text-sm);
    z-index: 1090;
    position: relative;
}
.app-release-banner-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    max-width: 1200px;
    margin: 0 auto;
}
.app-release-banner-version {
    font-weight: 600;
    white-space: nowrap;
}
.app-release-sidebar-footer {
    margin: var(--space-4);
    padding: var(--space-3);
    border-top: 1px solid var(--border-light);
    background: var(--medical-gray-50);
    border-radius: var(--radius-md);
}
.app-release-sidebar-version {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}
.app-release-sidebar-hint {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.35;
}
.app-release-login-footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}
.app-release-login-meta {
    display: block;
    margin-top: var(--space-2);
}
.app-release-login-version {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: var(--space-2);
}
.medical-logo .app-release-badge {
    margin-left: var(--space-2);
}

/* Nurse triage acuity badges (SATS colour coding) */
.triage-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    white-space: nowrap;
    vertical-align: middle;
    line-height: 1.2;
}

/* Modals above fixed portal headers (1080) and scrollable bodies for long forms */
.modal {
    --bs-modal-zindex: 1090;
}

.modal-backdrop {
    --bs-backdrop-zindex: 1085;
}

/* All standard modals (vitals, clinical notes, patient edit, orders, etc.) */
.modal .modal-dialog:not(.modal-fullscreen),
.modal .modal-dialog.modal-dialog-scrollable:not(.modal-fullscreen) {
    max-height: calc(100dvh - 2rem);
    margin-top: max(0.5rem, env(safe-area-inset-top, 0px));
    margin-bottom: max(0.5rem, env(safe-area-inset-bottom, 0px));
}

.modal .modal-dialog:not(.modal-fullscreen) .modal-content {
    max-height: calc(100dvh - 2rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal .modal-header,
.modal .modal-footer {
    flex-shrink: 0;
}

/* Form wraps only body + footer (edit patient) */
.modal .modal-content > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

/* Form wraps header + body + footer (vitals, journal entry) */
.modal .modal-content > form:only-child {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
}

.modal .modal-content > form .modal-header,
.modal .modal-content > form .modal-footer {
    flex-shrink: 0;
}

.modal .modal-body {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-height: 0;
}

/* Bootstrap scrollable dialog: keep body as scroll region */
.modal-dialog-scrollable .modal-body {
    overflow-y: auto;
}

.modal-dialog.modal-fullscreen .modal-content,
.modal-dialog.modal-fullscreen .modal-dialog {
    max-height: none;
}

/* Short centered dialogs (confirmations) — do not force viewport height */
.modal .modal-dialog.modal-dialog-centered.modal-sm .modal-content {
    max-height: none;
}

/* Speech-to-clinical notes in patient journal modal */
.clinical-note-stt-panel {
    background: linear-gradient(145deg, #1b3d1f 0%, #2e7d32 45%, #1b5e20 100%);
    border-radius: 10px;
    padding: 1rem 1.15rem;
    color: #fff;
}

.clinical-note-stt-title {
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0;
}

.clinical-note-stt-subtitle {
    opacity: 0.92;
    margin: 0;
}

.clinical-note-stt-preview {
    background: rgba(255, 255, 255, 0.97);
    color: var(--text-primary, #212121);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    min-height: 100px;
    max-height: 240px;
    overflow-y: auto;
    font-size: 0.875rem;
    line-height: 1.55;
    white-space: pre-wrap;
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.clinical-note-stt-preview.empty {
    color: var(--text-secondary, #757575);
    font-style: italic;
}

.clinical-note-stt-status {
    color: rgba(255, 255, 255, 0.9);
}

.clinical-note-stt-status[data-level="error"] {
    color: #ffcdd2;
}

.clinical-note-stt-status[data-level="success"] {
    color: #c8e6c9;
}

/* Patient clinical notes journal timeline */
.clinical-notes-timeline {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.clinical-notes-timeline-item {
    display: grid;
    grid-template-columns: 5.5rem 1rem 1fr;
    gap: 0.75rem 1rem;
    align-items: start;
}

.clinical-notes-timeline-time {
    text-align: right;
    padding-top: 0.35rem;
    line-height: 1.3;
}

.clinical-notes-timeline-marker {
    position: relative;
    width: 1rem;
    min-height: 100%;
}

.clinical-notes-timeline-marker::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 0.5rem;
    bottom: -1.25rem;
    width: 2px;
    margin-left: -1px;
    background: #c5ccd6;
}

.clinical-notes-timeline-item:last-child .clinical-notes-timeline-marker::before {
    bottom: 0.5rem;
}

.clinical-notes-timeline-marker::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 0.35rem;
    width: 12px;
    height: 12px;
    margin-left: -6px;
    border-radius: 50%;
    background: var(--bs-primary, #0d6efd);
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #c5ccd6;
}

@media (max-width: 575.98px) {
    .clinical-notes-timeline-item {
        grid-template-columns: 1fr;
    }

    .clinical-notes-timeline-time {
        text-align: left;
    }

    .clinical-notes-timeline-marker {
        display: none;
    }
}

/* Patient detail: header-embedded profile dropdown */
.patient-profile-integrated .patient-profile-chevron {
    display: inline-block;
    transition: transform 0.2s ease;
}

.patient-clinical-alerts-strip {
    background: var(--medical-white, #fff);
}

.patient-clinical-alerts-strip__isolation {
    word-break: break-word;
}

.patient-portal-isolation-banner {
    border-left-width: 4px;
}

/* POPIA: always-visible notice on authenticated portal pages. */
.portal-screenshot-guard-notice {
    font-size: 0.8125rem;
    z-index: 1075;
}

/* POPIA: discourage casual copy; watermark deters casual screenshots (not OS-proof). */
.portal-screenshot-guard--no-copy .medical-main,
.portal-screenshot-guard--no-copy .main-container {
    -webkit-user-select: none;
    user-select: none;
}

.portal-screenshot-guard--no-copy input,
.portal-screenshot-guard--no-copy textarea,
.portal-screenshot-guard--no-copy select,
.portal-screenshot-guard--no-copy [contenteditable="true"] {
    -webkit-user-select: text;
    user-select: text;
}

.portal-screenshot-guard--watermark::after {
    content: attr(data-screenshot-watermark);
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1040;
    opacity: 0.06;
    font-size: clamp(0.75rem, 2vw, 1rem);
    color: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transform: rotate(-24deg);
    white-space: pre-wrap;
    line-height: 2.5rem;
    background: repeating-linear-gradient(
        -24deg,
        transparent,
        transparent 120px,
        rgba(0, 0, 0, 0.02) 120px,
        rgba(0, 0, 0, 0.02) 240px
    );
}

.portal-screenshot-guard-toast {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    left: 1.25rem;
    max-width: 28rem;
    margin-left: auto;
    z-index: 1090;
    opacity: 0;
    transform: translateY(0.5rem);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.portal-screenshot-guard-toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

@media (min-width: 768px) {
    .portal-screenshot-guard-toast {
        left: auto;
    }
}

#patientProfileToggleBtn[aria-expanded="true"] .patient-profile-chevron {
    transform: rotate(180deg);
}

.patient-profile-accordion .accordion-button {
    font-size: 0.9rem;
}

.patient-profile-accordion .accordion-button:not(.collapsed) {
    background-color: rgba(13, 110, 253, 0.06);
}

/* Patient observation chart (monitoring tab) */
.observation-graph-selection {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.15rem 0.35rem;
    background: rgba(13, 110, 253, 0.04);
}

.observation-graph-selection-link {
    border: none;
    background: transparent;
    padding: 0.15rem 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--bs-primary);
    text-decoration: none;
    border-radius: 4px;
    cursor: pointer;
}

.observation-graph-selection-link:hover,
.observation-graph-selection-link:focus-visible {
    text-decoration: underline;
    outline: none;
}

.observation-graph-selection-link.active {
    color: var(--bs-body-color);
    text-decoration: underline;
    background: rgba(13, 110, 253, 0.12);
}

.observation-graph-selection-sep {
    color: var(--bs-border-color);
    font-size: 0.75rem;
    user-select: none;
}

.observation-chart-scroll {
    max-height: min(70vh, 640px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.observation-chart-table {
    table-layout: fixed;
    min-width: 900px;
    font-size: 0.8rem;
}

.observation-chart-sticky-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--bs-body-bg, #fff);
    min-width: 11rem;
    max-width: 14rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.04);
}

.observation-chart-param-header,
.observation-chart-param-label {
    font-weight: 600;
}

.observation-chart-hour-col {
    min-width: 2.25rem;
    width: 2.25rem;
    font-weight: 600;
    color: var(--bs-secondary-color);
}

.observation-chart-section-row th {
    background: rgba(13, 110, 253, 0.08);
    color: var(--bs-primary);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
}

.observation-chart-cell {
    color: var(--bs-secondary-color);
    padding: 0.2rem 0.15rem;
    vertical-align: middle;
}

.observation-chart-cell.has-value {
    color: var(--bs-body-color);
    font-weight: 600;
    background: rgba(13, 110, 253, 0.12);
    border-radius: 2px;
}

.observation-chart-cell.has-multiple {
    background: rgba(13, 110, 253, 0.18);
}

.observation-chart-value {
    line-height: 1.25;
    font-size: 0.72rem;
    white-space: nowrap;
}

.observation-chart-value + .observation-chart-value {
    margin-top: 0.15rem;
    padding-top: 0.15rem;
    border-top: 1px solid rgba(13, 110, 253, 0.2);
}

.observation-category-tabs .btn.active {
    font-weight: 600;
}

.monitoring-entry-history .card {
    border-left: 3px solid rgba(13, 110, 253, 0.35);
}

/* Hospital medication epic (inpatient / discharge / theatre) */
.hospital-med-table-scroll {
    max-height: min(65vh, 560px);
    overflow: auto;
}

.hospital-med-table {
    font-size: 0.78rem;
    min-width: 1200px;
}

.hospital-med-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bs-body-bg, #fff);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

.hospital-med-table thead th.hospital-med-sticky-col {
    left: 0;
    z-index: 4;
}

.hospital-med-table thead th.hospital-med-sticky-name {
    left: 2.5rem;
    z-index: 3;
    min-width: 10rem;
}

.hospital-med-row-standard {
    background: rgba(13, 202, 240, 0.12);
}

.hospital-med-row-analgesic {
    background: rgba(13, 202, 240, 0.22);
}

.hospital-med-row-cytotoxic {
    background: rgba(111, 66, 193, 0.15);
}

.hospital-med-row-anticoagulant {
    background: rgba(220, 53, 69, 0.12);
}

.hospital-med-scope-tabs .nav-link,
.hospital-med-module-tabs .nav-link {
    font-size: 0.85rem;
}

.hospital-med-admin-card .card-header {
    background: rgba(13, 110, 253, 0.06);
}

/* ============================================================
   UNIFIED PORTAL THEMING — one design language, per-portal accent
   Doctor = green, Admin = slate, Patient = blue. ID specificity
   overrides the :root defaults for every descendant, so all chrome
   and components that use --medical-primary* retint automatically.
   ============================================================ */
#doctorPortalRoot {
    --medical-primary: #2E7D32;        /* Green */
    --medical-primary-light: #4CAF50;
    --medical-primary-dark: #1B5E20;
}

#adminPortalRoot {
    --medical-primary: #37474F;        /* Slate */
    --medical-primary-light: #546E7A;
    --medical-primary-dark: #263238;
    /* Admin accent tokens must be mapped HERE (not on :root) so var(--medical-primary)
       resolves in the slate context and inherits down. Declaring them on :root would
       resolve against the green default and inherit green. */
    --admin-primary: var(--medical-primary);
    --admin-primary-dark: var(--medical-primary-dark);
    --admin-secondary: var(--medical-gray-800);
    --admin-accent: var(--medical-accent);
    --admin-success: var(--medical-success);
    --admin-danger: var(--medical-danger);
    --admin-warning: var(--medical-warning);
    --admin-info: var(--medical-info);
    --admin-bg: var(--bg-primary);
    --admin-card-bg: var(--medical-white);
    --admin-sidebar-bg: var(--medical-primary-dark);
}

#patientPortalRoot {
    --medical-primary: #1565C0;        /* Blue */
    --medical-primary-light: #42A5F5;
    --medical-primary-dark: #0D47A1;
}

/* ============================================================
   BRAND LOGO MARKS
   The app header bar is white, so it always shows the full-colour mark.
   (The white mark is kept in the DOM but hidden; it is only used on the
   gradient login header via .login-brand-logo.)
   ============================================================ */
.medical-logo .brand-mark {
    height: 34px;
    width: auto;
    display: inline-block;
    vertical-align: middle;
}
.medical-logo .brand-mark-white {
    display: none;
}
.login-brand-logo {
    height: 56px;
    width: auto;
}

/* ============================================================
   TOUCH / MOBILE / TABLET ENHANCEMENTS
   Smart-device first: large tap targets, no iOS zoom-on-focus,
   momentum scrolling, readable clinical tables, safe areas.
   ============================================================ */

/* Finger-friendly hit areas on touch / coarse-pointer devices */
@media (pointer: coarse) {
    .btn,
    .btn-medical,
    .nav-item,
    .dropdown-item,
    .form-control,
    .form-select,
    .input-group > .btn {
        min-height: 44px;
    }

    .btn,
    .btn-medical,
    .dropdown-item {
        padding-top: 0.6rem;
        padding-bottom: 0.6rem;
    }

    .nav-item {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    /* Roomier table rows so cells are tappable */
    .table > :not(caption) > * > * {
        padding-top: 0.8rem;
        padding-bottom: 0.8rem;
    }

    /* Bigger checkboxes / radios for touch */
    .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
        margin-top: 0.15rem;
    }

    /* Avoid accidental double-tap zoom on interactive elements */
    a,
    .btn,
    .btn-medical,
    .nav-item,
    .form-check-input {
        touch-action: manipulation;
    }
}

/* Prevent iOS Safari zooming the page when a field is focused */
@media (max-width: 575.98px) {
    .form-control,
    .form-select,
    input,
    textarea,
    select {
        font-size: 16px;
    }

    /* Opt-in helpers for full-width, thumb-friendly actions on phones */
    .btn-block-mobile {
        display: block;
        width: 100%;
    }

    .btn-group-mobile-block .btn {
        display: block;
        width: 100%;
    }

    .btn-group-mobile-block .btn + .btn {
        margin-top: 0.5rem;
    }
}

/* Momentum scrolling for any horizontally scrollable container */
@media (max-width: 991.98px) {
    .table-responsive,
    .observation-chart-scroll,
    .table-scroll {
        -webkit-overflow-scrolling: touch;
    }
}

/* Keep dense clinical tables legible on phones (was ~0.78rem) */
@media (max-width: 767.98px) {
    .observation-chart-table,
    .hospital-med-table {
        font-size: 0.85rem;
    }
}

/* Tablet: comfortable gutters between the mobile and desktop layouts */
@media (min-width: 768px) and (max-width: 1024px) {
    .medical-main {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }
}

/* Respect iOS notch / home-indicator safe areas */
@supports (padding: max(0px)) {
    .medical-sidebar {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    .medical-main {
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    }
}

/* ============================================================
   Modern status badges — soft tinted pills
   Loaded by every portal (doctor, patient, admin), so this is the
   single source of truth for badge styling. Colour variants are
   scoped to .badge so .bg-*/.text-bg-* on alerts, buttons, etc.
   are left untouched.
   ============================================================ */
.badge {
    font-weight: 600;
    font-size: 0.72rem;
    line-height: 1.5;
    letter-spacing: 0.01em;
    padding: 0.34em 0.72em;
    border-radius: 999px;
    vertical-align: middle;
}

/* Soft, low-saturation fills replace Bootstrap's loud solid badges. */
.badge.bg-success,   .badge.text-bg-success   { background-color: #E6F4EA !important; color: #1B7A3D !important; }
.badge.bg-warning,   .badge.text-bg-warning   { background-color: #FCEFD9 !important; color: #98590A !important; }
.badge.bg-danger,    .badge.text-bg-danger    { background-color: #FBE7E7 !important; color: #B42318 !important; }
.badge.bg-info,      .badge.text-bg-info      { background-color: #E1F1FA !important; color: #15607A !important; }
.badge.bg-primary,   .badge.text-bg-primary   { background-color: #E8EFFC !important; color: #1D4ED8 !important; }
.badge.bg-secondary, .badge.text-bg-secondary { background-color: #EEF1F4 !important; color: #516072 !important; }
.badge.bg-light,     .badge.text-bg-light     { background-color: #F1F3F5 !important; color: #495057 !important; }
.badge.bg-dark,      .badge.text-bg-dark      { background-color: #E7E9ED !important; color: #2B2F36 !important; }
.badge.bg-pink,      .badge.text-bg-pink      { background-color: #FCE7F1 !important; color: #A61E69 !important; }

/* Keep a hairline outline only where a border was explicitly requested. */
.badge.border { border-color: rgba(0, 0, 0, 0.08) !important; }

/* Consultation urgency pills (previously had no styling at all). */
.badge.urgency-low      { background-color: #E6F4EA !important; color: #1B7A3D !important; }
.badge.urgency-medium   { background-color: #FCEFD9 !important; color: #98590A !important; }
.badge.urgency-high     { background-color: #FBEAE0 !important; color: #B5460F !important; }
.badge.urgency-critical { background-color: #FBE7E7 !important; color: #B42318 !important; }

