/* ============================================
   Heartcare BP Monitor - Shared Styles
   Clean Medical Aesthetic
   ============================================ */

:root {
    /* Medical color palette */
    --bg: #F8FAFC;
    --bg-card: #FFFFFF;
    --bg-subtle: #F1F5F9;
    --border: #E2E8F0;
    --border-strong: #CBD5E1;
    
    --text: #0F172A;
    --text-secondary: #475569;
    --text-tertiary: #94A3B8;
    
    /* Heartcare brand */
    --brand: #872C2D;
    --brand-light: #FDF2F3;
    --brand-dark: #6B1F20;
    
    /* Medical blue (primary action) */
    --primary: #0369A1;
    --primary-light: #E0F2FE;
    --primary-dark: #075985;
    
    /* Status colors (BP categories) */
    --normal: #059669;
    --normal-bg: #D1FAE5;
    --elevated: #0891B2;
    --elevated-bg: #CFFAFE;
    --stage1: #D97706;
    --stage1-bg: #FEF3C7;
    --stage2: #EA580C;
    --stage2-bg: #FFEDD5;
    --crisis: #DC2626;
    --crisis-bg: #FEE2E2;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
    
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Typography */
h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 15px; font-weight: 600; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }

/* Layout */
.app-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text);
}

.topbar-brand img { height: 28px; }

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
    width: 100%;
    flex: 1;
}

.container-narrow {
    max-width: 480px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Auth pages */
.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(180deg, #F8FAFC 0%, #E0F2FE 100%);
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo img {
    height: 60px;
    margin-bottom: 12px;
}

.auth-title {
    text-align: center;
    margin-bottom: 8px;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 28px;
}

.auth-tabs {
    display: flex;
    background: var(--bg-subtle);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 24px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    transition: all 0.15s ease;
}

.auth-tab.active {
    background: var(--bg-card);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

/* Forms */
.form-group { margin-bottom: 16px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

input[type="text"], input[type="email"], input[type="password"], 
input[type="number"], input[type="date"], input[type="time"], 
select, textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font: inherit;
    font-size: 15px;
    color: var(--text);
    background: var(--bg-card);
    transition: all 0.15s ease;
    -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

input[type="number"] {
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    font-feature-settings: 'tnum';
}

textarea { resize: vertical; min-height: 80px; }

.checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
    background: var(--bg-subtle);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.checkbox-group label {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

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

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border-color: var(--border-strong);
}

.btn-secondary:hover { background: var(--bg-subtle); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover { background: var(--bg-subtle); color: var(--text); }

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

.btn-danger:hover { background: #B91C1C; }

.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-lg { padding: 14px 24px; font-size: 15px; }

.btn svg { width: 16px; height: 16px; }

/* BP Display */
.bp-input {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    background: var(--bg-subtle);
    border-radius: var(--radius);
}

.bp-input input {
    width: 100px;
    background: var(--bg-card);
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    border-color: var(--border-strong);
}

.bp-separator {
    font-size: 32px;
    font-weight: 300;
    color: var(--text-tertiary);
}

.bp-unit {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-left: 8px;
}

/* Status badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}

.badge-normal { background: var(--normal-bg); color: var(--normal); }
.badge-elevated { background: var(--elevated-bg); color: var(--elevated); }
.badge-stage1 { background: var(--stage1-bg); color: var(--stage1); }
.badge-stage2 { background: var(--stage2-bg); color: var(--stage2); }
.badge-crisis { background: var(--crisis-bg); color: var(--crisis); }

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    font-feature-settings: 'tnum';
    line-height: 1.1;
}

.stat-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Reading List */
.reading-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.reading-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.15s ease;
}

.reading-item:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}

.reading-bp {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    font-feature-settings: 'tnum';
    min-width: 90px;
}

.reading-meta {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
}

.reading-pulse {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error { background: var(--crisis); }
.toast.success { background: var(--normal); }

/* Empty state */
.empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}

.empty svg {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    opacity: 0.4;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-secondary);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2.5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Chart container */
.chart-wrap {
    position: relative;
    height: 280px;
    margin-top: 16px;
}

/* Time range selector */
.time-range {
    display: inline-flex;
    background: var(--bg-subtle);
    padding: 3px;
    border-radius: var(--radius);
}

.time-range button {
    border: none;
    background: transparent;
    padding: 6px 14px;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: calc(var(--radius) - 1px);
    cursor: pointer;
    transition: all 0.15s ease;
}

.time-range button.active {
    background: var(--bg-card);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

/* Notes */
.note-card {
    background: var(--primary-light);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 8px;
}

.note-meta {
    font-size: 12px;
    color: var(--primary-dark);
    font-weight: 500;
    margin-bottom: 4px;
}

.note-text {
    font-size: 14px;
    color: var(--text);
    line-height: 1.5;
}

/* Responsive */
@media (max-width: 640px) {
    .container { padding: 16px; }
    .card { padding: 20px; }
    .auth-card { padding: 28px 24px; }
    .topbar { padding: 10px 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .topbar-user span { display: none; }
}

/* Categories breakdown */
.category-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.category-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

.category-bar-label {
    width: 100px;
    color: var(--text-secondary);
}

.category-bar-track {
    flex: 1;
    height: 8px;
    background: var(--bg-subtle);
    border-radius: 4px;
    overflow: hidden;
}

.category-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.category-bar-value {
    width: 40px;
    text-align: right;
    font-weight: 500;
    color: var(--text);
}
