/* ═══════════════════════════════════════════════
   Salut — App personal de salut
   Mobile-first · Inter font · Agufy palette
   ═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --primary:      #2F5897;
    --primary-dark: #1e3d6b;
    --primary-light:#5a7db5;
    --primary-50:   #e8eef6;
    --green:        #10b981;
    --green-dark:   #059669;
    --green-light:  #d1fae5;
    --red:          #ef4444;
    --red-light:    #fee2e2;
    --amber:        #f59e0b;
    --amber-light:  #fef3c7;
    --gray-50:      #f9fafb;
    --gray-100:     #f3f4f6;
    --gray-200:     #e5e7eb;
    --gray-300:     #d1d5db;
    --gray-400:     #9ca3af;
    --gray-500:     #6b7280;
    --gray-600:     #4b5563;
    --gray-700:     #374151;
    --gray-800:     #1f2937;
    --gray-900:     #111827;
    --white:        #ffffff;
    --radius:       12px;
    --radius-sm:    8px;
    --radius-lg:    20px;
    --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --nav-h:        60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

/* ── Layout ──────────────────────────────────── */

main {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px 16px calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 24px);
    min-height: 100vh;
}

/* ── Bottom Nav ──────────────────────────────── */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    display: flex;
    align-items: flex-start;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-item {
    flex: 1;
    height: var(--nav-h);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--gray-400);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .02em;
    text-decoration: none;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
}

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

.nav-item svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Page header ─────────────────────────────── */

.page-header { padding: 8px 0 16px; }

.page-header h1 {
    font-size: 22px;
    font-weight: 800;
    color: var(--gray-900);
}

.page-header .subtitle {
    font-size: 14px;
    color: var(--gray-500);
    margin-top: 2px;
}

/* ── Cards ───────────────────────────────────── */

.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 12px;
}

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

.card-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .08em;
}

.card-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1;
}

.card-unit {
    font-size: 15px;
    font-weight: 500;
    color: var(--gray-500);
    margin-left: 2px;
}

/* ── Badges ──────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 100px;
}

.badge-green  { background: var(--green-light);  color: var(--green-dark); }
.badge-red    { background: var(--red-light);    color: var(--red); }
.badge-gray   { background: var(--gray-100);     color: var(--gray-500); }
.badge-amber  { background: var(--amber-light);  color: var(--amber); }
.badge-blue   { background: var(--primary-50);   color: var(--primary); }

/* ── Forms ───────────────────────────────────── */

.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 13px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 16px;
    color: var(--gray-800);
    background: var(--white);
    transition: border-color .15s;
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
}

.form-hint {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 4px;
}

/* ── Buttons ─────────────────────────────────── */

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    -webkit-tap-highlight-color: transparent;
}

.btn:active { opacity: .85; }

.btn-primary  { background: var(--primary); color: var(--white); }
.btn-green    { background: var(--green);   color: var(--white); }
.btn-outline  {
    background: var(--white);
    color: var(--gray-600);
    border: 2px solid var(--gray-200);
}

.btn-sm {
    width: auto;
    padding: 8px 16px;
    font-size: 14px;
}

/* ── Flash messages ──────────────────────────── */

.flash {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.flash-ok    { background: var(--green-light); color: var(--green-dark); }
.flash-error { background: var(--red-light);   color: var(--red); }

/* ── Exercises list ──────────────────────────── */

.exercise-list { list-style: none; }

.exercise-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 13px 0;
    border-bottom: 1px solid var(--gray-100);
}

.exercise-item:last-child { border-bottom: none; }

.exercise-num {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary-50);
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.exercise-info { flex: 1; }

.exercise-name {
    font-weight: 700;
    font-size: 15px;
    color: var(--gray-900);
}

.exercise-reps {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    margin-top: 2px;
}

.exercise-desc {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 2px;
    line-height: 1.4;
}

/* ── Heatmap ─────────────────────────────────── */

.heatmap-wrap {
    overflow-x: auto;
    padding-bottom: 4px;
}

.heatmap {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    min-width: 200px;
}

.heatmap-day-labels {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    margin-bottom: 4px;
}

.heatmap-day-label {
    text-align: center;
    font-size: 9px;
    font-weight: 700;
    color: var(--gray-400);
    text-transform: uppercase;
}

.hm-cell {
    aspect-ratio: 1;
    border-radius: 4px;
    background: var(--gray-100);
    position: relative;
}

.hm-cell.done  { background: var(--primary); }
.hm-cell.skip  { background: var(--gray-200); }
.hm-cell.rest  { background: var(--gray-100); opacity: .4; }
.hm-cell.today { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ── Nutrition toggles ───────────────────────── */

.nutr-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--gray-100);
}

.nutr-row:last-of-type { border-bottom: none; }

.nutr-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
}

.nutr-sub {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 1px;
}

.toggle-wrap {
    display: flex;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
}

.toggle-btn {
    padding: 8px 16px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, color .15s;
    -webkit-tap-highlight-color: transparent;
    color: var(--gray-400);
}

.toggle-btn.active-si  { background: var(--green); color: var(--white); }
.toggle-btn.active-no  { background: var(--red);   color: var(--white); }

/* ── Chart container ─────────────────────────── */

.chart-wrap {
    position: relative;
    width: 100%;
}

.chart-wrap canvas { width: 100% !important; }

/* ── Dashboard summary rows ──────────────────── */

.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
    text-decoration: none;
}

.summary-row:last-child { border-bottom: none; }

.summary-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.summary-icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--primary);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.summary-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
}

.summary-detail {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 1px;
}

.chevron {
    width: 16px;
    height: 16px;
    stroke: var(--gray-300);
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

/* ── Greeting ────────────────────────────────── */

.greeting {
    padding: 20px 0 4px;
}

.greeting-date {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    text-transform: capitalize;
    margin-bottom: 2px;
}

.greeting-name {
    font-size: 26px;
    font-weight: 800;
    color: var(--gray-900);
}

/* ── Streak number ───────────────────────────── */

.streak-big {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-top: 6px;
}

.streak-num {
    font-size: 48px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.streak-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-500);
}

/* ── Progress stats ──────────────────────────── */

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
}

.stat-card .stat-num {
    font-size: 28px;
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1;
}

.stat-card .stat-unit {
    font-size: 13px;
    color: var(--gray-400);
    font-weight: 500;
}

.stat-card .stat-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: .07em;
    margin-top: 4px;
}

/* ── Login page ──────────────────────────────── */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--gray-50);
}

.login-box {
    width: 100%;
    max-width: 380px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md, 0 4px 20px rgba(0,0,0,.08));
    padding: 32px 24px;
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo .app-name {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
}

.login-logo .app-tagline {
    font-size: 14px;
    color: var(--gray-500);
    margin-top: 2px;
}

/* ── Divider ─────────────────────────────────── */

.divider {
    height: 1px;
    background: var(--gray-100);
    margin: 16px 0;
}

/* ── Extra notes field ───────────────────────── */

#extra-notes-wrap {
    margin-top: 10px;
    display: none;
}

#extra-notes-wrap.visible { display: block; }

/* ── Desktop polish ──────────────────────────── */

@media (min-width: 480px) {
    .bottom-nav { max-width: 480px; left: 50%; transform: translateX(-50%); border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-left: 1px solid var(--gray-200); border-right: 1px solid var(--gray-200); }
    main { padding-top: 24px; }
}
