/* ============================================================
   CouchFit — Main Stylesheet
   Paleta: Verde (#40916C / #74C69D) + Rosa (#FF4D6D / #FF85A1)
   Mobile-first: base = 390px (iPhone 14 Pro)
   ============================================================ */

/* ── Variables ── */
:root {
    --green-900:  #1B4332;
    --green-700:  #2D6A4F;
    --green-500:  #40916C;
    --green-300:  #74C69D;
    --green-100:  #D8F3DC;

    --pink-700:   #C9184A;
    --pink-500:   #FF4D6D;
    --pink-300:   #FF85A1;
    --pink-100:   #FFD6E0;

    --surface:    #FFFFFF;
    --bg:         #F4F6F5;
    --text-main:  #1A1A2E;
    --text-muted: #6B7280;
    --border:     #E5E7EB;

    --grad-main:  linear-gradient(135deg, #40916C 0%, #FF4D6D 100%);
    --grad-green: linear-gradient(135deg, #2D6A4F 0%, #74C69D 100%);
    --grad-pink:  linear-gradient(135deg, #C9184A 0%, #FF85A1 100%);
    --grad-soft:  linear-gradient(135deg, #D8F3DC 0%, #FFD6E0 100%);

    --shadow-xs:  0 1px 4px rgba(0,0,0,.06);
    --shadow-sm:  0 2px 10px rgba(0,0,0,.09);
    --shadow-md:  0 4px 24px rgba(0,0,0,.13);
    --shadow-lg:  0 8px 40px rgba(0,0,0,.18);

    --r-sm:  12px;
    --r-md:  20px;
    --r-lg:  28px;
    --r-xl:  40px;

    --nav-h: 68px;         /* altura del bottom nav */
    --header-h: 64px;      /* altura del top header */
    --safe-bottom: env(safe-area-inset-bottom, 16px);
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text-main);
    min-height: 100dvh;
    overscroll-behavior-y: none;
    -webkit-font-smoothing: antialiased;
}

img, video { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, textarea, select { font: inherit; }

/* ── Typography ── */
.t-h1  { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
.t-h2  { font-size: 1.375rem; font-weight: 700; line-height: 1.3; }
.t-h3  { font-size: 1.125rem; font-weight: 600; }
.t-body { font-size: .9375rem; line-height: 1.6; }
.t-sm  { font-size: .8125rem; color: var(--text-muted); }
.t-xs  { font-size: .75rem; color: var(--text-muted); }

/* ── Layout helpers ── */
.page-wrapper {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100dvh;
    position: relative;
}

.main-content {
    padding: calc(var(--header-h) + 16px) 16px calc(var(--nav-h) + var(--safe-bottom) + 16px);
}

.section-gap { margin-bottom: 24px; }

/* ── Auth layout (login) ── */
.auth-wrapper {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    background: var(--grad-main);
    position: relative;
    overflow: hidden;
}

.auth-wrapper::before {
    content: '';
    position: absolute;
    width: 340px; height: 340px;
    border-radius: 50%;
    background: rgba(255,255,255,.07);
    top: -80px; right: -100px;
    pointer-events: none;
}

.auth-wrapper::after {
    content: '';
    position: absolute;
    width: 260px; height: 260px;
    border-radius: 50%;
    background: rgba(255,255,255,.05);
    bottom: -60px; left: -80px;
    pointer-events: none;
}

.auth-logo {
    text-align: center;
    margin-bottom: 36px;
    position: relative;
    z-index: 1;
}

.auth-logo-icon {
    width: 80px; height: 80px;
    background: rgba(255,255,255,.18);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,.3);
}

.auth-logo-icon svg { width: 42px; height: 42px; }

.auth-logo h1 {
    font-size: 1.875rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -.5px;
}

.auth-logo p {
    font-size: .875rem;
    color: rgba(255,255,255,.8);
    margin-top: 4px;
}

.auth-card {
    background: var(--surface);
    border-radius: var(--r-xl);
    padding: 32px 24px 28px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
}

.auth-card h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-main);
}

.auth-card .subtitle {
    font-size: .875rem;
    color: var(--text-muted);
    margin-bottom: 28px;
}

/* ── Form controls ── */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 7px;
}

.input-wrap {
    position: relative;
}

.input-wrap .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.form-control {
    width: 100%;
    padding: 13px 14px 13px 42px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    font-size: .9375rem;
    color: var(--text-main);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    -webkit-appearance: none;
}

.form-control:focus {
    border-color: var(--green-500);
    box-shadow: 0 0 0 3px rgba(64,145,108,.15);
    background: #fff;
}

.form-control.error { border-color: var(--pink-500); }

.toggle-pass {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    padding: 4px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: var(--r-sm);
    font-size: .9375rem;
    font-weight: 600;
    transition: all .2s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.btn-primary {
    background: var(--grad-main);
    color: #fff;
    box-shadow: 0 4px 16px rgba(64,145,108,.35);
}

.btn-primary:active { transform: scale(.97); box-shadow: none; }

.btn-secondary {
    background: var(--bg);
    color: var(--text-main);
    border: 1.5px solid var(--border);
}

.btn-green {
    background: var(--grad-green);
    color: #fff;
    box-shadow: 0 4px 14px rgba(64,145,108,.3);
}

.btn-pink {
    background: var(--grad-pink);
    color: #fff;
    box-shadow: 0 4px 14px rgba(255,77,109,.3);
}

.btn-block { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: .875rem; border-radius: 10px; }

.btn-loading { opacity: .7; pointer-events: none; }

/* ── Top header (páginas internas) ── */
.top-header {
    position: fixed;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    z-index: 100;
    gap: 12px;
    box-shadow: var(--shadow-xs);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.header-logo {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--grad-main);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-logo svg { width: 20px; height: 20px; color: #fff; }

.header-brand h1 {
    font-size: 1.125rem;
    font-weight: 700;
    background: var(--grad-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--grad-soft);
    border: 2px solid var(--green-300);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .875rem;
    font-weight: 700;
    color: var(--green-700);
    overflow: hidden;
    flex-shrink: 0;
}

.header-avatar img { width: 100%; height: 100%; object-fit: cover; }

.header-notification {
    position: relative;
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.notif-dot {
    width: 8px; height: 8px;
    background: var(--pink-500);
    border-radius: 50%;
    border: 2px solid var(--surface);
    position: absolute;
    top: 6px; right: 6px;
}

/* ── Bottom navigation ── */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: calc(var(--nav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    padding-top: 8px;
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0,0,0,.06);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 4px;
    color: var(--text-muted);
    transition: color .2s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.nav-item span { font-size: .65rem; font-weight: 500; }

.nav-item svg { width: 22px; height: 22px; }

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

.nav-item.active::before {
    content: '';
    position: absolute;
    top: -8px;
    width: 28px; height: 3px;
    border-radius: 0 0 4px 4px;
    background: var(--grad-main);
}

.nav-badge {
    position: absolute;
    top: 2px; right: calc(50% - 18px);
    min-width: 16px; height: 16px;
    background: var(--pink-500);
    color: #fff;
    font-size: .625rem;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--surface);
}

/* ── Cards ── */
.card {
    background: var(--surface);
    border-radius: var(--r-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.card-body { padding: 16px; }
.card-img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }

/* Motivation card (hero card) */
.motivation-card {
    border-radius: var(--r-lg);
    background: var(--grad-main);
    position: relative;
    overflow: hidden;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 24px;
}

.motivation-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 30%, rgba(0,0,0,.5) 100%);
}

.motivation-card__media {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    z-index: 0;
}

.motivation-card__content {
    position: relative;
    z-index: 1;
    color: #fff;
}

.motivation-card__label {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .5px;
    text-transform: uppercase;
    opacity: .85;
    margin-bottom: 6px;
}

.motivation-card__text {
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 8px;
}

.motivation-card__from {
    font-size: .8125rem;
    opacity: .8;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Section header */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 7px;
}

.section-title .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-green { background: var(--green-500); }
.dot-pink  { background: var(--pink-500); }

.section-link {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--green-500);
}

/* Routine day pill */
.day-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.day-scroll::-webkit-scrollbar { display: none; }

.day-pill {
    flex-shrink: 0;
    padding: 8px 16px;
    border-radius: 50px;
    font-size: .8125rem;
    font-weight: 600;
    background: var(--bg);
    color: var(--text-muted);
    border: 1.5px solid var(--border);
    transition: all .2s;
    -webkit-tap-highlight-color: transparent;
}

.day-pill.active {
    background: var(--grad-main);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 3px 10px rgba(64,145,108,.3);
}

/* Exercise item */
.exercise-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--surface);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-xs);
    margin-bottom: 8px;
    transition: transform .15s;
    -webkit-tap-highlight-color: transparent;
}

.exercise-item:active { transform: scale(.98); }

.exercise-thumb {
    width: 56px; height: 56px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--grad-soft);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--green-500);
}

.exercise-thumb svg { width: 24px; height: 24px; }

.exercise-info { flex: 1; min-width: 0; }

.exercise-info h4 {
    font-size: .9375rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.exercise-info .meta {
    font-size: .8125rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.exercise-play {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--grad-main);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(64,145,108,.3);
}

.exercise-play svg { width: 16px; height: 16px; color: #fff; }

/* Tip card */
.tip-card {
    display: flex;
    gap: 12px;
    padding: 14px;
    background: var(--surface);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-xs);
    margin-bottom: 8px;
}

.tip-icon {
    width: 42px; height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tip-icon.nutrition { background: var(--green-100); color: var(--green-700); }
.tip-icon.exercise  { background: var(--pink-100);  color: var(--pink-700); }
.tip-icon svg { width: 20px; height: 20px; }

.tip-content h4 { font-size: .9rem; font-weight: 600; }
.tip-content p  { font-size: .8125rem; color: var(--text-muted); margin-top: 3px; line-height: 1.5; }

/* Doubt form */
.doubt-textarea {
    width: 100%;
    min-height: 110px;
    resize: none;
    padding: 14px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    font-size: .9375rem;
    outline: none;
    transition: border-color .2s;
}
.doubt-textarea:focus {
    border-color: var(--green-500);
    box-shadow: 0 0 0 3px rgba(64,145,108,.12);
    background: #fff;
}

/* Greeting */
.greeting-block { padding: 8px 0 4px; }

.greeting-block .time-greeting {
    font-size: .8125rem;
    color: var(--text-muted);
    font-weight: 500;
}

.greeting-block .name {
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--grad-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.greeting-block .tagline {
    font-size: .875rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Progress ring */
.progress-ring-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border-radius: var(--r-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.progress-ring-text { flex: 1; }
.progress-ring-text h4 { font-size: .9375rem; font-weight: 700; }
.progress-ring-text p  { font-size: .8125rem; color: var(--text-muted); margin-top: 3px; }

/* Stat chips */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.stat-chip {
    background: var(--surface);
    border-radius: var(--r-sm);
    padding: 14px;
    box-shadow: var(--shadow-xs);
    text-align: center;
}

.stat-chip .value {
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--grad-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-chip .label { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

/* ── Alerts / Toasts ── */
.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--text-main);
    color: #fff;
    padding: 12px 20px;
    border-radius: 50px;
    font-size: .875rem;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    z-index: 999;
    opacity: 0;
    transition: all .3s cubic-bezier(.34,1.56,.64,1);
    white-space: nowrap;
    pointer-events: none;
}

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

.toast.success { background: var(--green-700); }
.toast.error   { background: var(--pink-700); }

/* ── Modal ── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(4px);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s;
}

.modal-backdrop.open { opacity: 1; pointer-events: all; }

.modal-sheet {
    position: fixed;
    bottom: 0; left: 50%;
    transform: translateX(-50%) translateY(100%);
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding: 20px 20px calc(24px + var(--safe-bottom));
    z-index: 201;
    transition: transform .4s cubic-bezier(.32,1,.32,1);
    max-height: 85dvh;
    overflow-y: auto;
}

.modal-sheet.open { transform: translateX(-50%) translateY(0); }

.modal-handle {
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 20px;
}

/* ── Spinner ── */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
    width: 20px; height: 20px;
    border: 2.5px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

/* ── Chip / Badge ── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: .75rem;
    font-weight: 600;
}

.chip-green { background: var(--green-100); color: var(--green-700); }
.chip-pink  { background: var(--pink-100);  color: var(--pink-700); }
.chip-gray  { background: var(--bg);        color: var(--text-muted); border: 1px solid var(--border); }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state svg { width: 56px; height: 56px; margin: 0 auto 12px; opacity: .35; }
.empty-state p   { font-size: .9375rem; }

/* ── Utilities ── */
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.items-center { align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-4   { margin-top: 4px; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mb-16  { margin-bottom: 16px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-white  { color: #fff !important; -webkit-text-fill-color: #fff !important; }

/* ── Animations ── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-up { animation: fadeInUp .45s ease both; }
.delay-1 { animation-delay: .1s; }
.delay-2 { animation-delay: .2s; }
.delay-3 { animation-delay: .3s; }
.delay-4 { animation-delay: .4s; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Large screens: center everything ── */
@media (min-width: 480px) {
    .page-wrapper { box-shadow: var(--shadow-lg); }
    .auth-wrapper { padding: 48px 24px; }
}
