/* ==========================================================
   PatientPortal -- Healthcare UI Theme
   Soft blue / green / white palette
   ========================================================== */

:root {
    --primary: #2c7be5;
    --primary-dark: #1a68d1;
    --primary-light: #e8f0fe;
    --secondary: #27ae60;
    --secondary-light: #e8f8f0;
    --accent: #00b894;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #17a2b8;
    --bg: #f0f4f8;
    --bg-card: #ffffff;
    --text: #2d3436;
    --text-muted: #636e72;
    --text-light: #b2bec3;
    --border: #dfe6e9;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --radius: 10px;
    --radius-sm: 6px;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --transition: all 0.25s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==========================================================
   SIDEBAR
   ========================================================== */

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e3a5f 0%, #2c3e50 100%);
    color: #ecf0f1;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.nav-links {
    list-style: none;
    padding: 16px 0;
    flex: 1;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #b2bec3;
    text-decoration: none;
    font-size: 0.95rem;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.nav-link:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.08);
}

.nav-link.active {
    color: #ffffff;
    background: rgba(44,123,229,0.2);
    border-left-color: var(--primary);
}

.nav-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.badge {
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    padding: 2px 7px;
    border-radius: 10px;
    margin-left: auto;
}

.badge.hidden {
    display: none;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.patient-selector label {
    display: block;
    font-size: 0.75rem;
    color: #b2bec3;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.patient-selector select {
    width: 100%;
    padding: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.1);
    color: #ecf0f1;
    font-size: 0.9rem;
}

.patient-selector select option {
    background: #2c3e50;
    color: #ecf0f1;
}

/* ==========================================================
   MAIN CONTENT
   ========================================================== */

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.top-bar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.top-bar h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.top-bar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
}

.patient-name {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text);
    cursor: pointer;
}

.app-container {
    padding: 24px;
    max-width: 1400px;
}

/* ==========================================================
   CARDS & GRID
   ========================================================== */

.grid {
    display: grid;
    gap: 20px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ==========================================================
   HEALTH SCORE GAUGE
   ========================================================== */

.health-score-gauge {
    text-align: center;
    padding: 24px;
}

.gauge-circle {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    border: 10px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    position: relative;
}

.gauge-score {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.gauge-grade {
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 4px;
}

.gauge-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ==========================================================
   STAT CARDS
   ========================================================== */

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-info h3 {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.stat-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ==========================================================
   PROGRESS BARS
   ========================================================== */

.progress-bar {
    height: 10px;
    background: var(--border);
    border-radius: 5px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.5s ease;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ==========================================================
   TIMELINE
   ========================================================== */

.timeline {
    position: relative;
    padding-left: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -26px;
    top: 20px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid white;
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.timeline-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.timeline-body {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ==========================================================
   TABLE
   ========================================================== */

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.data-table th {
    background: var(--bg);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.data-table tr:hover td {
    background: var(--primary-light);
}

/* ==========================================================
   STATUS BADGES
   ========================================================== */

.status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-normal { background: #e8f8f0; color: #27ae60; }
.status-high { background: #fde8e8; color: #e74c3c; }
.status-low { background: #fff3e0; color: #f39c12; }
.status-critical { background: #f5e6ff; color: #8e44ad; }
.status-active { background: #e8f0fe; color: #2c7be5; }
.status-inactive { background: #f0f0f0; color: #636e72; }

/* ==========================================================
   BUTTONS
   ========================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--secondary); color: white; }
.btn-success:hover { background: #219a52; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

/* ==========================================================
   FORMS
   ========================================================== */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: var(--transition);
    background: var(--bg-card);
    color: var(--text);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* ==========================================================
   MESSAGES
   ========================================================== */

.message-item {
    display: flex;
    gap: 12px;
    padding: 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.message-item:hover {
    background: var(--primary-light);
}

.message-item.unread {
    background: #f0f7ff;
    border-left: 3px solid var(--primary);
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.message-avatar.provider {
    background: var(--secondary);
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-subject {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.message-preview {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-light);
    flex-shrink: 0;
}

/* ==========================================================
   MODAL
   ========================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-overlay.hidden {
    display: none;
}

.modal-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-body {
    padding: 20px;
}

/* ==========================================================
   LOADING
   ========================================================== */

.loading-spinner {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
    font-size: 1rem;
}

/* ==========================================================
   WELLNESS CHARTS
   ========================================================== */

.wellness-ring {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 20px;
}

.ring-item {
    text-align: center;
}

.ring-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 6px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    font-size: 1.1rem;
    font-weight: 700;
}

.ring-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ==========================================================
   LAB RESULT INDICATORS
   ========================================================== */

.lab-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lab-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.lab-bar {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    position: relative;
    overflow: visible;
}

.lab-marker {
    position: absolute;
    top: -3px;
    width: 4px;
    height: 14px;
    background: var(--text);
    border-radius: 2px;
}

.lab-range {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(39, 174, 96, 0.25);
    border-radius: 4px;
}

/* ==========================================================
   RESPONSIVE
   ========================================================== */

@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .menu-toggle {
        display: block;
    }
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
    .wellness-ring {
        flex-wrap: wrap;
    }
}
