/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #7c3aed;
    --primary-dark: #6d28d9;
    --primary-light: #ede9fe;
    --success: #10b981;
    --danger: #ef4444;
    --bg: #f5f3ff;
    --card: #ffffff;
    --text: #1e1b4b;
    --text-muted: #7c6f9f;
    --border: #e9d5ff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding-bottom: 85px;
}

/* Header */
.header {
    background: linear-gradient(140deg, #3b0764 0%, #6d28d9 45%, #a855f7 100%);
    color: white;
    padding: 0.8rem 1.5rem 1.2rem;
    text-align: center;
    border-radius: 1px 0 50px 50px;
    box-shadow: 0 10px 32px rgba(109, 40, 217, .4);
    position: sticky;
    top: 0;
    z-index: 100;
    overflow: hidden;
    transition: padding .3s ease, border-radius .3s ease, box-shadow .3s ease;
}
.header::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: rgba(255,255,255,.07);
    pointer-events: none;
}
.header::after {
    content: '';
    position: absolute;
    bottom: -30px;
    left: -40px;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: rgba(255,255,255,.05);
    pointer-events: none;
}
.header-inner {
    position: relative;
    z-index: 1;
}
.header-deco {
    position: absolute;
    right: -22px;
    top: 50%;
    transform: translateY(-52%);
    width: 158px;
    height: 158px;
    pointer-events: none;
    z-index: 0;
}
.header h1 {
    font-size: 1.7rem;
    font-weight: 900;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: white;
    text-shadow: 0 2px 16px rgba(0,0,0,.2);
    transition: font-size .3s ease;
}
.header .subtitle {
    font-size: .73rem;
    color: rgba(255,255,255,.65);
    margin-top: .3rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    overflow: hidden;
    max-height: 2rem;
    opacity: 1;
    transition: max-height .3s ease, opacity .2s ease, margin-top .3s ease;
}

/* Header compact au scroll */
.header--scrolled {
    padding: .85rem 1.5rem .95rem;
    border-radius: 1px 0 22px 22px;
    box-shadow: 0 4px 18px rgba(109, 40, 217, .5);
}
.header--scrolled h1 {
    font-size: 1.05rem;
}
.header--scrolled .subtitle {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}
.header--scrolled .header-deco {
    width: 90px;
    height: 90px;
    transition: width .3s ease, height .3s ease;
}

/* Nav — bottom bar */
.nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: white;
    box-shadow: 0 -4px 28px rgba(124,58,237,.13);
    z-index: 200;
    padding: .5rem 0 .8rem;
}
.nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .18rem;
    text-decoration: none;
    padding: .45rem .5rem .2rem;
    color: #c4b5fd;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    transition: all .2s;
    border-bottom: none;
    white-space: nowrap;
}
.nav a .nav-icon {
    line-height: 1;
    transition: transform .2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav a .nav-icon svg {
    width: 23px;
    height: 23px;
    display: block;
}
.nav-label {
    display: block;
    overflow: hidden;
    max-height: 1.2rem;
    opacity: 1;
    transition: max-height .3s ease, opacity .2s ease;
}

.nav a:hover { color: var(--primary); }
.nav a.active {
    color: var(--primary);
    background: transparent;
}
.nav a.active .nav-icon { transform: scale(1.15); }

/* Container */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

/* Cards */
.card {
    background: var(--card);
    border-radius: 20px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 20px rgba(124,58,237,.08);
    border: 1px solid rgba(233,213,255,.7);
}
.card-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: .75rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--text);
}

/* BP Display */
.bp-display {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
}
.bp-value {
    flex: 1;
    min-width: 75px;
    text-align: center;
    padding: .75rem .5rem;
    background: var(--bg);
    border-radius: 14px;
}
.bp-value .label { font-size: .68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.bp-value .value { font-size: 1.6rem; font-weight: 800; color: var(--primary); line-height: 1.2; }
.bp-value .unit  { font-size: .68rem; color: var(--text-muted); }

/* Status badges */
.status-badge {
    display: inline-block;
    padding: .28rem .85rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
}
.status-normal   { background: #d1fae5; color: #065f46; }
.status-elevated { background: #fef3c7; color: #92400e; }
.status-high1    { background: #fce7f3; color: #9d174d; }
.status-high2    { background: #fee2e2; color: #991b1b; }
.status-crisis   { background: #991b1b; color: white; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .75rem 1.5rem;
    border-radius: 50px;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    border: none;
    transition: all .2s;
    -webkit-tap-highlight-color: transparent;
    line-height: 1;
}
.btn-primary   { background: var(--primary); color: white; box-shadow: 0 4px 14px rgba(124,58,237,.35); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success   { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-danger    { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: var(--primary-light); color: var(--primary); }
.btn-secondary:hover { background: #ddd6fe; }
.btn-soft-danger { background: #fce7f3; color: #9d174d; }
.btn-soft-danger:hover { background: #fbcfe8; }
.btn-sm   { padding: .38rem .85rem; font-size: .78rem; }
.btn-full { width: 100%; }

/* FAB */
.fab {
    position: fixed;
    bottom: 5.5rem;
    right: 1.5rem;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 22px rgba(124,58,237,.5);
    text-decoration: none;
    z-index: 150;
    transition: all .2s;
}
.fab:hover { background: var(--primary-dark); transform: scale(1.07); }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .875rem; font-weight: 700; margin-bottom: .4rem; color: var(--text); }
.form-control {
    width: 100%;
    padding: .75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 14px;
    font-size: 1rem;
    color: var(--text);
    background: white;
    transition: border-color .2s;
    -webkit-appearance: none;
    appearance: none;
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .75rem; }

/* Period toggle */
.period-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.period-btn {
    padding: .875rem;
    border: 2px solid var(--border);
    border-radius: 14px;
    background: white;
    cursor: pointer;
    text-align: center;
    font-size: .9rem;
    font-weight: 700;
    color: var(--text-muted);
    transition: all .2s;
    user-select: none;
}
.period-btn.selected { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
input[name="period"] { display: none; }

/* Reading row */
.reading-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem .75rem;
    background: var(--bg);
    border-radius: 12px;
    margin-bottom: .4rem;
}
.reading-vals   { flex: 1; min-width: 0; }
.reading-main   { font-size: 1.05rem; font-weight: 700; }
.reading-detail { font-size: .78rem; color: var(--text-muted); margin-top: .1rem; }
.reading-actions { display: flex; gap: .35rem; flex-shrink: 0; }

/* Average block */
.avg-block {
    background: var(--primary-light);
    border: 1px solid #ddd6fe;
    border-radius: 14px;
    padding: .875rem 1rem;
    margin-top: .75rem;
}
.avg-title  { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--primary); font-weight: 700; margin-bottom: .4rem; }
.avg-values { display: flex; gap: .4rem; font-size: .88rem; font-weight: 600; flex-wrap: wrap; }
.avg-values span { background: white; padding: .18rem .55rem; border-radius: 8px; }

/* Day card header */
.day-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: .6rem; flex-wrap: wrap; gap: .4rem; }
.day-date { font-size: 1rem; font-weight: 700; color: var(--text); }
.day-date .sub { font-size: .82rem; color: var(--text-muted); font-weight: 400; display: block; }

/* Period section */
.period-section { margin-top: .75rem; }
.period-label {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    padding-bottom: .3rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: .5rem;
}

/* Stats */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: 1rem; }
.stat-card {
    background: var(--card);
    border-radius: 16px;
    padding: 1rem;
    text-align: center;
    border: 1px solid rgba(233,213,255,.7);
    box-shadow: 0 4px 14px rgba(124,58,237,.07);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 90px;
}
.stat-number { font-size: 1.6rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label  { font-size: .72rem; color: var(--text-muted); margin-top: .3rem; }
.stat-card-min { background: #fef2f2; border-color: #fecaca; }
.stat-card-min .stat-number { color: #e53e3e; }
.stat-card-max { background: #f0fdf4; border-color: #bbf7d0; }
.stat-card-max .stat-number { color: #16a34a; }

/* Chart */
.chart-container { position: relative; height: 240px; margin-top: .5rem; }

/* Alerts */
.alert { padding: .75rem 1rem; border-radius: 14px; margin-bottom: 1rem; font-size: .875rem; font-weight: 500; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info    { background: var(--primary-light); color: var(--primary); border: 1px solid #ddd6fe; }

/* Empty state */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }

/* Table */
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { padding: .5rem .6rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--bg); font-weight: 700; color: var(--text-muted); }

/* Responsive */
@media (max-width: 420px) {
    .form-row-3 { grid-template-columns: 1fr 1fr; }
    .bp-value .value { font-size: 1.3rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 640px) {
    .container { padding: 1.5rem; }
    .card { padding: 1.5rem; }
}
