/* ==========================================================================
   Smart BurnAid v2.0 - Professional Design System
   Multi-page PWA with Chatbot, Doctor Dashboard, Assessment History
   ========================================================================== */

:root {
    /* Colors */
    --color-primary: #007AFF;
    --color-success: #34C759;
    --color-warning: #FF9500;
    --color-danger: #FF3B30;
    --color-purple: #AF52DE;
    --color-teal: #5AC8FA;

    /* Backgrounds */
    --bg-primary: #F2F2F7;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: rgba(118, 118, 128, 0.12);

    /* Text */
    --text-primary: #000000;
    --text-secondary: rgba(60, 60, 67, 0.6);
    --text-tertiary: rgba(60, 60, 67, 0.3);

    /* Separator */
    --separator: rgba(60, 60, 67, 0.12);

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;

    /* Font Sizes */
    --text-xs: 11px;
    --text-sm: 13px;
    --text-base: 15px;
    --text-md: 17px;
    --text-lg: 20px;
    --text-xl: 22px;
    --text-2xl: 28px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

    /* Bottom nav height */
    --nav-height: 70px;
}

/* Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    font-size: var(--text-md);
    line-height: 1.4;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* App Container */
.app-container {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* ======================================================================
   RESPONSIVE LAYOUT
   ====================================================================== */
@media (min-width: 768px) {

    .page-content,
    .app-header .header-content {
        max-width: 800px;
        margin-left: auto;
        margin-right: auto;
    }

    .bottom-nav {
        max-width: 500px;
        margin: 0 auto;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
}

@media (min-width: 1200px) {

    .page-content,
    .app-header .header-content {
        max-width: 960px;
    }
}

/* ======================================================================
   HEADER
   ====================================================================== */
.app-header {
    padding: var(--space-3) var(--space-4);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--separator);
    flex-shrink: 0;
    z-index: 10;
}

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

.app-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    overflow: hidden;
    flex-shrink: 0;
}

.app-icon svg {
    width: 100%;
    height: 100%;
}

.header-text {
    flex: 1;
}

.header-text h1 {
    font-size: var(--text-lg);
    font-weight: 700;
    letter-spacing: -0.3px;
}

.header-text p {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.language-toggle {
    width: 44px;
    height: 32px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
}

.language-toggle:active {
    opacity: 0.7;
    transform: scale(0.95);
}

/* ======================================================================
   PAGE CONTENT (Multi-page navigation)
   ====================================================================== */
.page-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-4);
    padding-bottom: calc(var(--nav-height) + var(--space-4));
    -webkit-overflow-scrolling: touch;
    display: none;
}

.page-content.active {
    display: block;
    animation: pageIn 0.3s ease;
}

@keyframes pageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ======================================================================
   BOTTOM NAVIGATION
   ====================================================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 0.5px solid var(--separator);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 8px);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-1) var(--space-3);
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-family: var(--font-family);
    transition: color 0.2s;
    position: relative;
}

.nav-item span {
    font-size: 10px;
    font-weight: 500;
}

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

.nav-item.active::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background: var(--color-primary);
    border-radius: 1px;
}

.nav-item:active {
    transform: scale(0.92);
}

/* ======================================================================
   QUICK STATS DASHBOARD
   ====================================================================== */
.quick-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 18px;
    height: 18px;
}

.stat-icon-total {
    background: rgba(0, 122, 255, 0.12);
    color: var(--color-primary);
}

.stat-icon-recent {
    background: rgba(52, 199, 89, 0.12);
    color: var(--color-success);
}

.stat-icon-patients {
    background: rgba(175, 82, 222, 0.12);
    color: var(--color-purple);
}

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

.stat-value {
    font-size: var(--text-lg);
    font-weight: 700;
    line-height: 1.1;
}

.stat-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ======================================================================
   CONNECTION SECTION
   ====================================================================== */
.connection-section {
    margin-bottom: var(--space-4);
}

.connection-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.connection-status {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-tertiary);
}

.status-indicator.connected {
    background: var(--color-success);
    box-shadow: 0 0 8px rgba(52, 199, 89, 0.4);
}

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

.connection-title {
    font-size: var(--text-base);
    font-weight: 600;
}

.connection-subtitle {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.connect-btn {
    padding: 6px 14px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-tertiary);
    font-family: var(--font-family);
}

.connection-hint {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    text-align: center;
    margin-top: var(--space-2);
}

/* ======================================================================
   SECTION HEADER
   ====================================================================== */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.section-header h2 {
    font-size: var(--text-lg);
    font-weight: 700;
}

.section-badge {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-primary);
    background: rgba(0, 122, 255, 0.1);
    padding: 4px 10px;
    border-radius: 100px;
}

/* ======================================================================
   INPUT FORM
   ====================================================================== */
.input-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.patient-info-card,
.input-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.patient-info-card {
    margin-bottom: var(--space-3);
}

.input-card:focus-within {
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.3);
}

.input-card.disabled {
    opacity: 0.5;
}

.input-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.input-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.input-icon svg {
    width: 20px;
    height: 20px;
}

.temp-icon {
    background: linear-gradient(135deg, #FF6B6B, #ee5a24);
}

.humidity-icon {
    background: linear-gradient(135deg, #4FACFE, #00f2fe);
}

.resistance-icon {
    background: linear-gradient(135deg, #A78BFA, #7c3aed);
}

.patient-icon {
    background: linear-gradient(135deg, #667EEA, #764BA2);
}

.area-icon {
    background: linear-gradient(135deg, #11998e, #38ef7d);
}

.input-label {
    display: flex;
    flex-direction: column;
}

.label-title {
    font-size: var(--text-base);
    font-weight: 600;
}

.label-unit {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.input-field {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.input-field input {
    flex: 1;
    border: none;
    background: transparent;
    padding: var(--space-3);
    font-size: var(--text-xl);
    font-weight: 600;
    font-family: var(--font-family);
    color: var(--text-primary);
    text-align: right;
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

.input-field input[type="text"] {
    text-align: left;
    font-size: var(--text-md);
    font-weight: 500;
}

.input-field input::-webkit-outer-spin-button,
.input-field input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
}

.input-field input::placeholder {
    color: var(--text-tertiary);
}

.input-field input:focus {
    outline: none;
}

.input-suffix {
    padding: var(--space-3);
    font-size: var(--text-md);
    font-weight: 500;
    color: var(--text-secondary);
}

.input-range {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-2);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

/* Body Area Selector */
.body-area-selector {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.area-btn {
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: 100px;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    font-family: var(--font-family);
    transition: all 0.2s;
}

.area-btn:hover {
    background: rgba(0, 122, 255, 0.08);
}

.area-btn.selected {
    background: rgba(0, 122, 255, 0.12);
    border-color: var(--color-primary);
    color: var(--color-primary);
    font-weight: 600;
}

/* ======================================================================
   BUTTONS
   ====================================================================== */
.action-buttons {
    margin-top: var(--space-4);
}

.btn-primary {
    width: 100%;
    padding: var(--space-4);
    background: linear-gradient(135deg, #007AFF, #0055FF);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-md);
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 122, 255, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
    opacity: 0.9;
}

.btn-secondary {
    width: 100%;
    padding: var(--space-4);
    background: var(--bg-tertiary);
    color: var(--color-primary);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-md);
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s;
    margin-top: var(--space-4);
    margin-bottom: var(--space-6);
}

.btn-secondary:active {
    opacity: 0.8;
}

.btn-action {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--separator);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-primary);
    cursor: pointer;
    font-family: var(--font-family);
    transition: all 0.2s;
}

.btn-action:hover {
    background: rgba(0, 122, 255, 0.05);
}

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

.result-actions {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.result-actions .btn-action {
    flex: 1;
    justify-content: center;
}

/* ======================================================================
   LOADING SECTION
   ====================================================================== */
.analysis-loading {
    padding: var(--space-6) 0;
}

.loading-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    text-align: center;
    box-shadow: var(--shadow-md);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    margin: 0 auto var(--space-4);
    animation: spin 1s linear infinite;
}

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

.loading-title {
    font-size: var(--text-lg);
    font-weight: 700;
    margin-bottom: var(--space-1);
}

.loading-subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
}

.loading-progress {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: var(--space-5);
}

.loading-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), #5AC8FA);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 2px;
}

.loading-steps {
    text-align: left;
}

.step {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    transition: color 0.3s;
}

.step.active {
    color: var(--text-primary);
}

.step.complete {
    color: var(--color-success);
}

.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    flex-shrink: 0;
    transition: background 0.3s;
}

.step.active .step-dot {
    background: var(--color-primary);
}

.step.complete .step-dot {
    background: var(--color-success);
}

/* ======================================================================
   RESULTS SECTION
   ====================================================================== */
.results-section {
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Severity Card */
.severity-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-md);
    border-left: 4px solid var(--text-tertiary);
}

.severity-superficial {
    border-left-color: var(--color-success);
}

.severity-partial {
    border-left-color: var(--color-warning);
}

.severity-deep {
    border-left-color: var(--color-danger);
}

.severity-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.severity-icon-wrapper {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.severity-info {
    flex: 1;
}

.severity-label {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.severity-title {
    font-size: var(--text-lg);
    font-weight: 700;
    margin-top: 2px;
}

.severity-alt {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.severity-risk {
    padding: 4px 12px;
    border-radius: 100px;
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
}

.severity-desc {
    margin-top: var(--space-4);
    font-size: var(--text-base);
    color: var(--text-secondary);
    line-height: 1.5;
}

.severity-meta {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--separator);
}

.meta-item {
    display: flex;
    justify-content: space-between;
}

.meta-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.meta-value {
    font-size: var(--text-sm);
    font-weight: 600;
}

/* Severity States */
.severity-superficial .severity-icon-wrapper {
    background: rgba(52, 199, 89, 0.15);
    color: #248A3D;
}

.severity-superficial .severity-title {
    color: #248A3D;
}

.severity-superficial .severity-risk {
    background: rgba(52, 199, 89, 0.15);
    color: #248A3D;
}

.severity-partial .severity-icon-wrapper {
    background: rgba(255, 149, 0, 0.15);
    color: #C93400;
}

.severity-partial .severity-title {
    color: #C93400;
}

.severity-partial .severity-risk {
    background: rgba(255, 149, 0, 0.15);
    color: #C93400;
}

.severity-deep .severity-icon-wrapper {
    background: rgba(255, 59, 48, 0.15);
    color: #D70015;
}

.severity-deep .severity-title {
    color: #D70015;
}

.severity-deep .severity-risk {
    background: rgba(255, 59, 48, 0.15);
    color: #D70015;
}

/* Analysis Breakdown */
.analysis-breakdown {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-sm);
}

.breakdown-title {
    font-size: var(--text-sm);
    font-weight: 600;
    margin-bottom: var(--space-3);
}

.breakdown-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.breakdown-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.breakdown-header {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-sm);
}

.breakdown-label {
    color: var(--text-secondary);
}

.breakdown-value {
    font-weight: 600;
}

.breakdown-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.breakdown-fill {
    height: 100%;
    width: 0%;
    transition: width 0.8s ease;
    border-radius: 3px;
}

.breakdown-fill.superficial {
    background: var(--color-success);
}

.breakdown-fill.partial {
    background: var(--color-warning);
}

.breakdown-fill.deep {
    background: var(--color-danger);
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.metric-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.metric-value {
    font-size: var(--text-base);
    font-weight: 700;
    display: block;
}

.metric-label {
    font-size: 10px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Guidance Section */
.guidance-section {
    margin-bottom: var(--space-4);
}

.guidance-header {
    margin-bottom: var(--space-3);
}

.guidance-header h3 {
    font-size: var(--text-md);
    font-weight: 700;
}

.guidance-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    box-shadow: var(--shadow-sm);
}

.guidance-card h4 {
    font-size: var(--text-base);
    font-weight: 600;
    margin-bottom: var(--space-3);
}

.guidance-card ul {
    list-style: none;
}

.guidance-card li {
    position: relative;
    padding-left: var(--space-4);
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}

.guidance-card li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 7px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.guidance-card.safe li::before {
    background: var(--color-success);
}

.guidance-card.warning li::before {
    background: var(--color-danger);
}

/* Disclaimer */
.disclaimer-card {
    background: rgba(255, 149, 0, 0.08);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    border-left: 3px solid var(--color-warning);
}

.disclaimer-content strong {
    font-size: var(--text-sm);
    display: block;
    margin-bottom: var(--space-1);
}

.disclaimer-content p {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ======================================================================
   CHATBOT PAGE
   ====================================================================== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 130px);
    margin: calc(-1 * var(--space-4));
    margin-bottom: calc(-1 * var(--nav-height) - var(--space-4));
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--separator);
}

.chat-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.chat-header-text h2 {
    font-size: var(--text-md);
    font-weight: 700;
}

.chat-status-text {
    font-size: var(--text-xs);
    color: var(--color-success);
    font-weight: 500;
}

.chat-quick-actions {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    overflow-x: auto;
    scrollbar-width: none;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--separator);
}

.chat-quick-actions::-webkit-scrollbar {
    display: none;
}

.quick-action-btn {
    padding: 8px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--separator);
    border-radius: 100px;
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--color-primary);
    cursor: pointer;
    white-space: nowrap;
    font-family: var(--font-family);
    transition: all 0.2s;
}

.quick-action-btn:hover {
    background: rgba(0, 122, 255, 0.08);
}

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

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    -webkit-overflow-scrolling: touch;
}

.chat-message {
    display: flex;
    gap: var(--space-2);
    max-width: 85%;
    animation: messageIn 0.3s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.bot-message {
    align-self: flex-start;
}

.bot-avatar {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    margin-top: 4px;
}

.user-message .message-content {
    background: var(--color-primary);
    color: white;
    border-radius: var(--radius-md) var(--radius-md) 4px var(--radius-md);
}

.bot-message .message-content {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: var(--radius-md) var(--radius-md) var(--radius-md) 4px;
    box-shadow: var(--shadow-sm);
}

.message-content {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    line-height: 1.6;
}

.message-content p {
    margin: 0;
}

.message-text {
    word-break: break-word;
}

.message-time {
    display: block;
    font-size: 10px;
    opacity: 0.5;
    margin-top: var(--space-1);
    text-align: right;
}

/* Typing indicator */
.typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--text-tertiary);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-6px);
    }
}

.chat-input-container {
    padding: var(--space-3) var(--space-4);
    padding-bottom: calc(var(--nav-height) + var(--space-3));
    background: var(--bg-secondary);
    border-top: 1px solid var(--separator);
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--bg-tertiary);
    border-radius: 100px;
    padding: 4px 4px 4px var(--space-4);
}

.chat-input-wrapper input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: var(--text-base);
    font-family: var(--font-family);
    color: var(--text-primary);
    padding: var(--space-2) 0;
    outline: none;
}

.chat-input-wrapper input::placeholder {
    color: var(--text-tertiary);
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    background: var(--color-primary);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
}

.chat-send-btn:not(:disabled):hover {
    transform: scale(1.05);
}

.chat-send-btn:not(:disabled):active {
    transform: scale(0.95);
}

/* ======================================================================
   DOCTOR DASHBOARD PAGE
   ====================================================================== */
.doctor-auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.auth-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    text-align: center;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.auth-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-4);
}

.auth-card h2 {
    font-size: var(--text-xl);
    font-weight: 700;
    margin-bottom: var(--space-1);
}

.auth-subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-5);
}

.auth-form {
    text-align: left;
}

.auth-input-group {
    margin-bottom: var(--space-4);
}

.auth-input-group label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    margin-bottom: var(--space-1);
    color: var(--text-secondary);
}

.auth-input-group input,
.auth-input-group select {
    width: 100%;
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: var(--text-md);
    font-family: var(--font-family);
    color: var(--text-primary);
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.auth-input-group input:focus,
.auth-input-group select:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Doctor Dashboard */
.doctor-profile-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-sm);
}

.doctor-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.doctor-info {
    flex: 1;
}

.doctor-name-display {
    font-size: var(--text-base);
    font-weight: 600;
    display: block;
}

.doctor-specialty-display {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.doctor-logout-btn {
    width: 36px;
    height: 36px;
    background: rgba(255, 59, 48, 0.1);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-danger);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.doctor-logout-btn:hover {
    background: rgba(255, 59, 48, 0.2);
}

/* Dashboard Stats */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.dash-stat-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    text-align: center;
    box-shadow: var(--shadow-sm);
    border-top: 3px solid transparent;
}

.dash-stat-patients {
    border-top-color: var(--color-primary);
}

.dash-stat-critical {
    border-top-color: var(--color-danger);
}

.dash-stat-moderate {
    border-top-color: var(--color-warning);
}

.dash-stat-mild {
    border-top-color: var(--color-success);
}

.dash-stat-value {
    font-size: var(--text-2xl);
    font-weight: 700;
    display: block;
}

.dash-stat-label {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Patient Cards */
.patients-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.patient-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

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

.patient-superficial {
    border-left-color: var(--color-success);
}

.patient-partial {
    border-left-color: var(--color-warning);
}

.patient-deep {
    border-left-color: var(--color-danger);
}

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

.patient-card-name {
    font-size: var(--text-base);
    font-weight: 600;
}

.patient-card-date {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    display: block;
}

.severity-badge {
    padding: 3px 10px;
    border-radius: 100px;
    font-size: var(--text-xs);
    font-weight: 600;
}

.severity-mild {
    background: rgba(52, 199, 89, 0.12);
    color: #248A3D;
}

.severity-moderate {
    background: rgba(255, 149, 0, 0.12);
    color: #C93400;
}

.severity-critical {
    background: rgba(255, 59, 48, 0.12);
    color: #D70015;
}

.patient-card-body {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-2);
}

.patient-metric {
    text-align: center;
}

.pm-label {
    font-size: 10px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    display: block;
}

.pm-value {
    font-size: var(--text-sm);
    font-weight: 600;
}

.doctor-note-preview {
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--separator);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    line-height: 1.4;
}

.filter-controls {
    display: flex;
    gap: var(--space-2);
}

.filter-select {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-primary);
    font-family: var(--font-family);
    cursor: pointer;
}

/* Patient Detail Modal */
.patient-detail-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 85vh;
    width: 100%;
    max-width: 500px;
    overflow-y: auto;
    animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--separator);
    position: sticky;
    top: 0;
    z-index: 1;
}

.modal-header h3 {
    font-size: var(--text-md);
    font-weight: 700;
}

.modal-close {
    width: 30px;
    height: 30px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-4) var(--space-5);
}

.modal-actions {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
    background: var(--bg-secondary);
    border-top: 1px solid var(--separator);
}

.modal-actions .btn-action {
    flex: 1;
    justify-content: center;
}

/* Detail sections */
.detail-section {
    margin-bottom: var(--space-5);
}

.detail-section h4 {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-3);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
}

.detail-item {
    background: var(--bg-secondary);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
}

.detail-label {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    display: block;
}

.detail-value {
    font-size: var(--text-sm);
    font-weight: 600;
}

.detail-severity {
    background: var(--bg-secondary);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-3);
    border-left: 3px solid var(--text-tertiary);
}

.detail-severity-superficial {
    border-left-color: var(--color-success);
}

.detail-severity-partial {
    border-left-color: var(--color-warning);
}

.detail-severity-deep {
    border-left-color: var(--color-danger);
}

.detail-severity-name {
    font-size: var(--text-md);
    font-weight: 700;
    display: block;
}

.detail-severity-alt {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.detail-description {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: var(--space-3);
}

.detail-bars {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.detail-bar-item {
    display: grid;
    grid-template-columns: 80px 1fr 40px;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
}

.detail-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.detail-bar-fill {
    height: 100%;
    border-radius: 3px;
}

.detail-bar-fill.superficial {
    background: var(--color-success);
}

.detail-bar-fill.partial {
    background: var(--color-warning);
}

.detail-bar-fill.deep {
    background: var(--color-danger);
}

.doctor-note-full {
    background: var(--bg-secondary);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    line-height: 1.5;
    color: var(--text-secondary);
    border-left: 3px solid var(--color-primary);
}

/* ======================================================================
   HISTORY PAGE
   ====================================================================== */
.history-header-section {
    margin-bottom: var(--space-4);
}

.btn-clear-history {
    width: 36px;
    height: 36px;
    background: rgba(255, 59, 48, 0.1);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-danger);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-chart-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-top: var(--space-3);
    box-shadow: var(--shadow-sm);
}

.history-chart-container canvas {
    width: 100%;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.history-item {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    border-left: 3px solid transparent;
    transition: transform 0.2s;
}

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

.history-superficial {
    border-left-color: var(--color-success);
}

.history-partial {
    border-left-color: var(--color-warning);
}

.history-deep {
    border-left-color: var(--color-danger);
}

.history-item-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.history-severity-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.history-item-info {
    display: flex;
    flex-direction: column;
}

.history-item-title {
    font-size: var(--text-base);
    font-weight: 600;
}

.history-item-subtitle {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.history-item-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-align: right;
}

.history-item-readings {
    display: flex;
    flex-direction: column;
}

.history-metric {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
}

.history-item-date {
    font-size: 10px;
    color: var(--text-tertiary);
    line-height: 1.3;
}

/* ======================================================================
   EMPTY STATE
   ====================================================================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-6) var(--space-4);
    text-align: center;
    color: var(--text-tertiary);
}

.empty-state p {
    font-size: var(--text-sm);
    max-width: 250px;
    line-height: 1.5;
}

/* ======================================================================
   INSTALL BANNER
   ====================================================================== */
.install-banner {
    position: fixed;
    bottom: calc(var(--nav-height) + 10px);
    left: 50%;
    transform: translateX(-50%);
    max-width: 360px;
    width: calc(100% - 40px);
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    z-index: 150;
}

.install-text {
    color: white;
}

.install-text strong {
    font-size: var(--text-base);
    display: block;
}

.install-text span {
    font-size: var(--text-xs);
    opacity: 0.7;
}

.install-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.install-btn {
    padding: 8px 16px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 100px;
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-family);
}

.install-dismiss {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ======================================================================
   ERROR TOAST
   ====================================================================== */
.error-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 59, 48, 0.95);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    z-index: 1000;
    animation: slideDown 0.3s ease;
    transition: opacity 0.3s;
    max-width: 90%;
    text-align: center;
}

.success-toast {
    background: rgba(52, 199, 89, 0.95) !important;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ======================================================================
   UTILITIES
   ====================================================================== */
.hidden {
    display: none !important;
}

/* ======================================================================
   DARK MODE
   ====================================================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #000000;
        --bg-secondary: #1C1C1E;
        --bg-tertiary: rgba(118, 118, 128, 0.24);
        --text-primary: #FFFFFF;
        --text-secondary: rgba(235, 235, 245, 0.6);
        --text-tertiary: rgba(235, 235, 245, 0.3);
        --separator: rgba(84, 84, 88, 0.65);
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
        --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    }

    .bottom-nav {
        background: rgba(28, 28, 30, 0.92);
    }

    .app-header {
        background: rgba(28, 28, 30, 0.95);
    }

    .chat-header-info {
        background: rgba(28, 28, 30, 0.95);
    }

    .chat-input-container {
        background: rgba(28, 28, 30, 0.95);
    }
}