/**
 * style.css — Mobile-First Responsive Styles for Saúde Tracker
 * 
 * DESIGN PHILOSOPHY:
 * 1. Mobile-first: Base styles target phones (360px+), then scale up
 * 2. CSS Custom Properties (variables) for consistent theming
 * 3. Touch-friendly: Minimum 44px tap targets
 * 4. Medical status colors: green (normal), amber (warning), red (critical)
 * 5. Modern aesthetics: gradients, rounded corners, subtle shadows, micro-animations
 */

/* ============================================================
   CSS CUSTOM PROPERTIES (VARIABLES)
   These define our design tokens — colors, spacing, fonts.
   Change these to instantly retheme the entire app!
   ============================================================ */
:root {
    /* Primary gradient — used for headers, buttons, accents */
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --primary-light: #a3bffa;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    /* Background & surface colors */
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --bg-card-hover: #f8f9ff;

    /* Text colors */
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #a0aec0;
    --text-on-primary: #ffffff;

    /* Medical status colors */
    --color-normal: #48bb78;
    --color-normal-bg: #f0fff4;
    --color-normal-border: #c6f6d5;
    --color-warning: #ed8936;
    --color-warning-bg: #fffaf0;
    --color-warning-border: #feebc8;
    --color-critical: #f56565;
    --color-critical-bg: #fff5f5;
    --color-critical-border: #fed7d7;
    --color-info: #4299e1;
    --color-info-bg: #ebf8ff;

    /* Spacing scale (consistent spacing throughout) */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Border radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: 0.7rem;
    --font-size-sm: 0.8rem;
    --font-size-base: 0.95rem;
    --font-size-lg: 1.1rem;
    --font-size-xl: 1.35rem;
    --font-size-2xl: 1.7rem;

    /* Transition */
    --transition: all 0.2s ease;

    /* Navigation heights */
    --header-height: 56px;
    --bottom-nav-height: 64px;
}


/* ============================================================
   RESET & BASE STYLES
   Normalize browser defaults for consistent cross-browser look.
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    background: var(--bg-body);
    line-height: 1.6;
    min-height: 100vh;
    /* Add padding for fixed header and bottom nav */
    padding-top: var(--header-height);
    padding-bottom: calc(var(--bottom-nav-height) + 16px);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}


/* ============================================================
   APP HEADER (Fixed top bar)
   ============================================================ */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--primary-gradient);
    color: var(--text-on-primary);
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 var(--space-md);
    max-width: 1200px;
    margin: 0 auto;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-on-primary);
    font-weight: 700;
    font-size: var(--font-size-lg);
}

.app-logo:hover {
    color: var(--text-on-primary);
    opacity: 0.9;
}

.logo-img {
    height: 24px;
    width: auto;
    border-radius: 6px;
}

/* Language Switcher */
.lang-switcher {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-full);
    padding: 3px;
}

.lang-btn {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    transition: var(--transition);
    letter-spacing: 0.5px;
}

.lang-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
}

.lang-btn.active {
    color: var(--primary-dark);
    background: #fff;
}


/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    min-height: calc(100vh - var(--header-height) - var(--bottom-nav-height));
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: var(--space-md);
}


/* ============================================================
   FLASH MESSAGES
   Notification bar that slides in from the top.
   ============================================================ */
.flash-message {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    padding: var(--space-md);
    font-weight: 500;
    text-align: center;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    transition: all 0.3s ease;
    font-size: var(--font-size-sm);
}

.flash-success {
    background: var(--color-normal-bg);
    color: #276749;
    border-bottom: 2px solid var(--color-normal);
}

.flash-error {
    background: var(--color-critical-bg);
    color: #c53030;
    border-bottom: 2px solid var(--color-critical);
}

.flash-warning {
    background: var(--color-warning-bg);
    color: #c05621;
    border-bottom: 2px solid var(--color-warning);
}

.flash-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.6;
    padding: var(--space-xs);
}

.flash-close:hover {
    opacity: 1;
}


/* ============================================================
   BOTTOM NAVIGATION BAR
   Fixed to the bottom of the screen — like a native app.
   ============================================================ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-card);
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    padding-bottom: env(safe-area-inset-bottom);
    /* iPhone notch safety */
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: var(--space-xs) var(--space-sm);
    color: var(--text-muted);
    font-size: var(--font-size-xs);
    border: none;
    background: none;
    cursor: pointer;
    min-width: 56px;
    min-height: 44px;
    /* Minimum touch target size */
    border-radius: var(--radius-sm);
    transition: var(--transition);
    text-decoration: none;
}

.nav-item:hover,
.nav-item.active {
    color: var(--primary);
}

.nav-item.active {
    position: relative;
}

.nav-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--primary-gradient);
    border-radius: 0 0 3px 3px;
}

.nav-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.nav-label {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 64px;
}


/* ============================================================
   MORE MENU (Slide-up panel)
   ============================================================ */
.more-menu {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1001;
}

.more-menu.open {
    display: block;
}

.more-menu-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    animation: fadeIn 0.2s ease;
}

.more-menu-content {
    position: absolute;
    bottom: var(--bottom-nav-height);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: var(--space-md);
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.25s ease;
}

.more-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-weight: 500;
    min-height: 48px;
    transition: var(--transition);
}

.more-menu-item:hover,
.more-menu-item.active {
    background: var(--bg-card-hover);
    color: var(--primary);
}


/* ============================================================
   CARD COMPONENT
   Used everywhere: dashboard cards, form cards, list items.
   ============================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    margin-bottom: var(--space-md);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.card-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.card-icon {
    font-size: 1.5rem;
}


/* ============================================================
   PAGE TITLE
   ============================================================ */
.page-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.page-title .icon {
    font-size: 1.6rem;
}

.page-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: calc(-1 * var(--space-md));
    margin-bottom: var(--space-lg);
}


/* ============================================================
   DASHBOARD GRID
   Responsive card grid using CSS Grid.
   ============================================================ */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

/* Vital summary card on the dashboard */
.vital-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    transition: var(--transition);
    cursor: pointer;
    border-left: 4px solid transparent;
    text-decoration: none;
    color: inherit;
}

.vital-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.vital-card.status-normal {
    border-left-color: var(--color-normal);
}

.vital-card.status-warning {
    border-left-color: var(--color-warning);
}

.vital-card.status-critical {
    border-left-color: var(--color-critical);
}

.vital-card.status-unknown {
    border-left-color: var(--text-muted);
}

.vital-icon {
    font-size: 2rem;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-body);
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.vital-info {
    flex: 1;
    min-width: 0;
}

.vital-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

.vital-value {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.vital-unit {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    font-weight: 400;
}

.vital-meta {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: 2px;
}


/* ============================================================
   STATUS BADGES
   Color-coded indicators for medical readings.
   ============================================================ */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    white-space: nowrap;
}

.status-badge.normal {
    background: var(--color-normal-bg);
    color: #276749;
    border: 1px solid var(--color-normal-border);
}

.status-badge.warning {
    background: var(--color-warning-bg);
    color: #c05621;
    border: 1px solid var(--color-warning-border);
}

.status-badge.critical {
    background: var(--color-critical-bg);
    color: #c53030;
    border: 1px solid var(--color-critical-border);
}


/* ============================================================
   BODY METRICS GRID (BMI, BMR, WHtR, WHR)
   ============================================================ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.metric-item {
    background: var(--bg-body);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
    text-align: center;
}

.metric-label {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: var(--font-size-lg);
    font-weight: 700;
    margin: 4px 0;
}

.metric-desc {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}


/* ============================================================
   FORMS
   Mobile-friendly, large touch targets.
   ============================================================ */
.form-group {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.form-control {
    width: 100%;
    padding: 12px var(--space-md);
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    transition: var(--transition);
    min-height: 44px;
    /* Touch target */
    -webkit-appearance: none;
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%234a5568' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.form-hint {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: 4px;
}

.form-error {
    font-size: var(--font-size-xs);
    color: var(--color-critical);
    margin-top: 4px;
}


/* ============================================================
   BUTTONS
   Large, touch-friendly, with clear visual hierarchy.
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 12px var(--space-lg);
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    min-height: 44px;
    /* Touch target */
    min-width: 44px;
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-gradient);
    color: var(--text-on-primary);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    color: var(--text-on-primary);
}

.btn-secondary {
    background: var(--bg-body);
    color: var(--text-secondary);
    border: 2px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #e2e8f0;
    color: var(--text-primary);
}

.btn-danger {
    background: var(--color-critical);
    color: white;
}

.btn-danger:hover {
    background: #e53e3e;
    color: white;
}

.btn-success {
    background: var(--color-normal);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: var(--font-size-sm);
    min-height: 36px;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-group {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}


/* ============================================================
   DATA TABLE
   Responsive table that scrolls horizontally on mobile.
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
}

.data-table th,
.data-table td {
    padding: var(--space-md);
    text-align: left;
    border-bottom: 1px solid #edf2f7;
    font-size: var(--font-size-sm);
}

.data-table th {
    background: var(--bg-body);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.data-table tr:hover {
    background: var(--bg-card-hover);
}

.data-table tr:last-child td {
    border-bottom: none;
}


/* ============================================================
   READING CARDS (alternative to table for mobile)
   Each record shown as a card instead of table row.
   ============================================================ */
.reading-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-sm);
    border-left: 4px solid var(--text-muted);
    transition: var(--transition);
}

.reading-card.normal {
    border-left-color: var(--color-normal);
}

.reading-card.warning {
    border-left-color: var(--color-warning);
}

.reading-card.critical {
    border-left-color: var(--color-critical);
}

.reading-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-sm);
}

.reading-card-value {
    font-size: var(--font-size-xl);
    font-weight: 700;
}

.reading-card-meta {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.reading-card-body {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.reading-card-tag {
    font-size: var(--font-size-xs);
    padding: 2px 8px;
    background: var(--bg-body);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
}

.reading-card-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
    padding-top: var(--space-sm);
    border-top: 1px solid #edf2f7;
}


/* ============================================================
   QUICK ADD BUTTONS (Dashboard)
   ============================================================ */
.quick-add-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
}

.quick-add-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-md);
    background: var(--bg-card);
    border: 2px solid #edf2f7;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-align: center;
    transition: var(--transition);
    min-height: 72px;
    cursor: pointer;
    text-decoration: none;
}

.quick-add-btn:hover {
    border-color: var(--primary-light);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.quick-add-btn .icon {
    font-size: 1.4rem;
}


/* ============================================================
   CHART CONTAINER
   ============================================================ */
.chart-container {
    position: relative;
    width: 100%;
    max-height: 300px;
    margin: var(--space-md) 0;
}

.chart-period-selector {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
}

.period-btn {
    padding: 6px 14px;
    border: 2px solid #e2e8f0;
    background: var(--bg-card);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
}

.period-btn:hover,
.period-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(102, 126, 234, 0.05);
}


/* ============================================================
   EMPTY STATE
   Shown when there's no data yet.
   ============================================================ */
.empty-state {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.empty-state p {
    margin-bottom: var(--space-lg);
}


/* ============================================================
   FOOTER
   ============================================================ */
.app-footer {
    text-align: center;
    padding: var(--space-lg);
    color: var(--text-muted);
    font-size: var(--font-size-xs);
    margin-bottom: var(--space-xl);
}


/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.animate-in {
    animation: fadeIn 0.3s ease, slideDown 0.3s ease;
}


/* ============================================================
   SEVERITY DOTS (for health notes)
   ============================================================ */
.severity-dots {
    display: inline-flex;
    gap: 3px;
}

.severity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e2e8f0;
}

.severity-dot.filled.low {
    background: var(--color-normal);
}

.severity-dot.filled.med {
    background: var(--color-warning);
}

.severity-dot.filled.high {
    background: var(--color-critical);
}


/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.text-sm {
    font-size: var(--font-size-sm);
}

.text-xs {
    font-size: var(--font-size-xs);
}

.text-normal {
    color: var(--color-normal);
}

.text-warning {
    color: var(--color-warning);
}

.text-critical {
    color: var(--color-critical);
}

.mt-sm {
    margin-top: var(--space-sm);
}

.mt-md {
    margin-top: var(--space-md);
}

.mt-lg {
    margin-top: var(--space-lg);
}

.mb-sm {
    margin-bottom: var(--space-sm);
}

.mb-md {
    margin-bottom: var(--space-md);
}

.mb-lg {
    margin-bottom: var(--space-lg);
}

.flex {
    display: flex;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gap-sm {
    gap: var(--space-sm);
}

.gap-md {
    gap: var(--space-md);
}

.hidden {
    display: none;
}


/* ============================================================
   RESPONSIVE BREAKPOINTS
   Mobile-first: base styles are for phones (360px+).
   Then we enhance for tablets and desktops.
   ============================================================ */

/* Tablets (600px+) */
@media (min-width: 600px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .quick-add-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .metrics-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Desktop (900px+) */
@media (min-width: 900px) {
    :root {
        --header-height: 60px;
    }

    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .container {
        padding: var(--space-lg) var(--space-xl);
    }

    .quick-add-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    /* On desktop, we could convert bottom nav to sidebar — but bottom nav
       works well on all screen sizes, so we keep it for consistency. */
    .nav-label {
        max-width: none;
    }
}

/* Large desktop (1200px+) */
@media (min-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}


/* ============================================================
   AUTH PAGES — Login, Register, Forgot/Reset Password
   Full-screen centered card layout for authentication flows.
   ============================================================ */

/* The body class on auth pages — gradient background */
.auth-body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    font-family: var(--font-family);
}

/* Centering wrapper for the auth card */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: authFadeIn 0.4s ease-out;
}

@keyframes authFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-header {
    text-align: center;
    margin-bottom: var(--space-lg);
}

.auth-header .auth-logo {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    object-fit: contain;
}

.auth-header h1 {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.auth-header .auth-tagline {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    margin: 0;
}

/* Links below the form (forgot password, register) */
.auth-links {
    text-align: center;
    margin-top: var(--space-lg);
    font-size: var(--font-size-sm);
}

.auth-links a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.auth-links a:hover {
    text-decoration: underline;
}

.auth-divider {
    margin: 0 var(--space-sm);
    color: var(--text-muted);
}

/* Auth-specific footer (outside the card) */
.auth-body .app-footer {
    background: none;
    color: rgba(255, 255, 255, 0.6);
    border: none;
    padding: var(--space-md);
}

.auth-body .app-footer p {
    color: rgba(255, 255, 255, 0.6);
    font-size: var(--font-size-xs);
}

.auth-error,
.auth-success {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.auth-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.auth-success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.auth-link {
    display: block;
    text-align: right;
    margin-top: -8px;
    margin-bottom: var(--space-md);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.auth-link a {
    color: var(--primary);
    text-decoration: none;
}


/* Welcome-back card for remembered users */
.wb-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-body);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    border-left: 4px solid var(--primary);
    animation: authFadeIn 0.35s ease-out;
}

.wb-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: var(--text-on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xl);
    font-weight: 700;
    flex-shrink: 0;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.wb-info {
    flex: 1;
    min-width: 0;
}

.wb-greeting {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 2px;
}

.wb-name {
    font-size: var(--font-size-base);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wb-email {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wb-not-you {
    font-size: var(--font-size-sm);
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    background: none;
    border: none;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    text-decoration: none;
    font-family: var(--font-family);
}

.wb-not-you:hover {
    background: rgba(102, 126, 234, 0.08);
    text-decoration: underline;
}


/* ============================================================
   HEADER USER INFO
   Shows logged-in user's avatar and name in the header bar.
   ============================================================ */
.header-user {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-on-primary);
}

.header-user:hover {
    opacity: 0.85;
}

.header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.header-username {
    font-size: var(--font-size-sm);
    font-weight: 600;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-admin-link {
    color: var(--text-on-primary);
    font-size: 1.2rem;
    margin-left: 4px;
    text-decoration: none;
    opacity: 0.8;
    transition: var(--transition);
}

.header-admin-link:hover {
    opacity: 1;
    transform: scale(1.1);
}

@media (max-width: 400px) {
    .header-username {
        display: none;
    }
}


/* ============================================================
   ADMIN PAGES — Dashboard & User Management
   ============================================================ */
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.admin-stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.admin-stat-card .stat-icon {
    font-size: 2rem;
    margin-bottom: var(--space-sm);
}

.admin-stat-card .stat-value {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--text-primary);
}

.admin-stat-card .stat-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: 2px;
}

.admin-stat-card .stat-sub {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.admin-user-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.admin-user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.admin-user-info {
    flex: 1;
    min-width: 120px;
}

.admin-user-info .user-name {
    font-weight: 600;
    color: var(--text-primary);
}

.admin-user-info .user-email {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.admin-user-actions {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
    align-items: center;
}

.admin-search-form {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.admin-search-form .form-control {
    flex: 1;
}

@media (min-width: 768px) {
    .admin-stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .admin-stats-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}


/* ============================================================
   PROFILE PHOTO
   ============================================================ */
.profile-photo-section {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.profile-photo-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.profile-photo-input {
    flex: 1;
}


/* ============================================================
   UTILITY — btn-success (used in admin & medications)
   ============================================================ */
.btn-success {
    background: var(--success);
    color: #fff;
    border: none;
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: var(--font-size-sm);
    transition: var(--transition);
}

.btn-success:hover {
    filter: brightness(0.9);
}