/* ================================================================
   header.css — CHROME COMPARTIDO (cabecera + menú lateral)
   ----------------------------------------------------------------
   Barra superior glassmorphism + botones de icono + menú lateral
   deslizable + overlay. La enlazan LAS 5 páginas para que la
   navegación se sienta idéntica en toda la app.
   ================================================================ */

#app-header,
#app-main { position: relative; z-index: 1; }
#app-header { z-index: 100; }

/* --- Barra superior (fixed, glassmorphism) --- */
#app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    /* La barra se extiende hacia ARRIBA cubriendo el área segura del notch
       (iPhone): así el cristal oscuro rellena esa zona y no aparece una banda
       gris bajo la barra. En móviles sin notch, env(...) = 0 → no cambia nada. */
    height: calc(var(--header-height) + env(safe-area-inset-top));

    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 16px;
    /* El padding-top mete el área segura del notch DENTRO de la barra: el
       contenido (menú/título/iconos) queda por debajo del notch y el cristal
       lo rellena. Va en el shorthand para que no lo pise otra regla. */
    padding: env(safe-area-inset-top) 16px 0;

    background-color: var(--header-bg-color);
    background-image: var(--header-gradient);
    border-bottom: 1px solid var(--header-border);
    box-shadow: var(--shadow-header);

    -webkit-backdrop-filter: var(--header-blur);
    backdrop-filter: var(--header-blur);

    z-index: 100;
}

/* Wordmark: insignia con onda de sonido + texto */
.app-title {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;          /* sin justify-self:start: el bloque ocupa su columna
                              (1fr) y el texto se ajusta sin desbordar/solaparse */
}
.app-logo {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--brand-purple-light, #B85EFF), var(--brand-purple, #8A2BE2));
    box-shadow: 0 2px 9px rgba(138, 43, 226, 0.45),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.app-logo svg { width: 17px; height: 17px; color: #fff; display: block; }
.app-title__text {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 1.45rem;      /* con el nombre fuera de la barra hay sitio: marca con presencia */
    font-weight: 800;
    letter-spacing: -0.5px;
    /* Degradado blanco→lila: el mismo del login (marca coherente en toda la app) */
    background: linear-gradient(120deg, #ffffff, #d9c2ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.header-icons {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;        /* el lado derecho nunca se recorta contra el borde */
}

/* El NOMBRE ya no va en la barra (vive en el saludo del home y en el menú
   lateral): así "Path Accent" respira y no se corta en pantallas estrechas. */
.profile-name { display: none !important; }

/* El wordmark NUNCA se corta ("Path Acce…" prohibido): con el anillo de la
   meta al lado, el texto cede tamaño ANTES que perder letras (Axel, 16-jul). */
@media (max-width: 430px) {
    .app-title__text { font-size: 1.18rem; }
}
@media (max-width: 380px) {
    .app-title__text { font-size: 1.02rem; }
}

/* El botón de perfil siempre redondo (con avatar o sin él): así el aro de
   racha 🔥 abraza un círculo de verdad y nada se ve ovalado ni recortado. */
.profile-btn {
    border-radius: 50%;
    overflow: hidden;
    /* Círculo PERFECTO siempre: sin esto el flex lo estiraba a óvalo cuando no
       hay avatar (cazado por Axel, 17-jul). Tamaño fijo y sin encogerse. */
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    aspect-ratio: 1 / 1;
    padding: 0;
    box-sizing: border-box;
}
/* SIN mascota todavía (primer arranque): hueco acogedor con huella — un
   "aquí va tu perro" a propósito, no un aro vacío que parece foto rota. */
.profile-btn:not(.profile-btn--has-avatar) {
    background: linear-gradient(180deg, rgba(168, 90, 240, 0.38) 0%, rgba(94, 23, 160, 0.5) 100%);
    border: 1.5px dashed rgba(255, 255, 255, 0.55);
    color: rgba(255, 255, 255, 0.92);
}
.profile-btn__avatar {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.profile-btn__fallback {
    fill: currentColor;      /* huella RELLENA (el .header-svg general va a trazo) */
    stroke: none;
    width: 19px;
    height: 19px;
}

/* --- Racha diaria (llama + días seguidos, la pinta js/streak.js) --- */
.streak-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px 5px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.10);
    user-select: none;
}
.streak-badge__flame {
    width: 18px;
    height: 18px;
    fill: #5d6472;                       /* apagada: gris */
    transition: fill 0.3s ease, filter 0.3s ease;
}
.streak-badge__num {
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    font-size: 0.95rem;
    line-height: 1;
    color: #8a93a3;                      /* apagada: gris */
    transition: color 0.3s ease;
}
/* Encendida: hoy ya practicaste — una llama VIVA, no un icono soso (Axel) */
.streak-badge--lit {
    background: linear-gradient(135deg, rgba(255, 140, 0, 0.20), rgba(255, 80, 0, 0.10));
    border-color: rgba(255, 150, 0, 0.45);
    box-shadow: 0 0 12px rgba(255, 130, 0, 0.25), inset 0 1px 0 rgba(255, 200, 120, 0.25);
}
.streak-badge--lit .streak-badge__flame {
    fill: #ff9600;
    filter: drop-shadow(0 0 7px rgba(255, 130, 0, 0.75));
    animation: flame-flicker 2.2s ease-in-out infinite;
    transform-origin: 50% 85%;
}
.streak-badge--lit .streak-badge__num {
    color: #ffc266;
    text-shadow: 0 0 10px rgba(255, 140, 0, 0.55);
}
/* Parpadeo de fuego real: la llama respira y se ladea un pelín (solo GPU) */
@keyframes flame-flicker {
    0%, 100% { transform: scale(1)          rotate(0deg); }
    25%      { transform: scale(1.08, 0.95) rotate(-2deg); }
    50%      { transform: scale(0.96, 1.06) rotate(1.5deg); }
    75%      { transform: scale(1.05, 0.97) rotate(-1deg); }
}
@media (prefers-reduced-motion: reduce) {
    .streak-badge--lit .streak-badge__flame { animation: none; }
}

/* Salto de celebración cuando la racha sube */
@keyframes streak-pop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.35) rotate(-6deg); }
    70%  { transform: scale(0.92); }
    100% { transform: scale(1); }
}
.streak-badge--pop .streak-badge__flame {
    animation: streak-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: 50% 80%;
}

/* --- Botón de icono (compartido header + X del menú) --- */
.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;

    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted-color);

    cursor: pointer;
    border-radius: var(--radius-icon-btn);
    transition: background-color var(--transition-base),
                color var(--transition-base),
                transform var(--transition-base);
}
.icon-btn:hover {
    background-color: var(--icon-btn-hover-bg);
    color: var(--text-color);
    transform: translateY(-1px);
}
.icon-btn:active { transform: translateY(0); }
.icon-btn:focus-visible {
    outline: 2px solid var(--brand-purple);
    outline-offset: 2px;
}

.header-svg {
    width: 22px;
    height: 22px;
    display: block;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
    pointer-events: none;
}

/* --- Menú lateral deslizable --- */
#side-menu {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--side-menu-width);
    max-width: 85vw;

    display: flex;
    flex-direction: column;

    background-color: var(--dark-bg-color);
    background-image: linear-gradient(180deg, rgba(138, 43, 226, 0.07), transparent 28%);
    border-right: 1px solid var(--border-soft-color);
    box-shadow: var(--shadow-lg);

    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    z-index: 200;
}
body.side-menu-open #side-menu { transform: translateX(0); }

.side-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: calc(var(--header-height) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 14px 0 20px;
    border-bottom: 1px solid var(--border-soft-color);
    flex-shrink: 0;
}
.side-menu-title {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.3px;
    color: var(--text-color);
    opacity: 0.9;
}
.side-menu-content {
    flex: 1;
    padding: 16px 14px;
    color: var(--text-color);
    font-size: 0.95rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
/* Enlaces de navegación del menú lateral */
.side-menu-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 16px;
    border-radius: var(--radius-control);
    color: var(--text-muted-color);
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.side-menu-link i {
    width: 22px;
    flex-shrink: 0;
    text-align: center;
    font-size: 1.05rem;
    color: var(--brand-purple-light);
    opacity: 0.8;
    transition: opacity 0.2s ease;
}
.side-menu-link:hover {
    background: linear-gradient(90deg, rgba(138, 43, 226, 0.16), rgba(138, 43, 226, 0.03));
    color: var(--text-color);
    transform: translateX(4px);
}
.side-menu-link:hover i { opacity: 1; }
.side-menu-link:active { transform: scale(0.98); }
.side-menu-link[aria-current="page"] {
    background: linear-gradient(90deg, rgba(138, 43, 226, 0.24), rgba(138, 43, 226, 0.05));
    color: var(--brand-purple-light);
    font-weight: 700;
}
.side-menu-link[aria-current="page"] i { opacity: 1; }
.side-menu-link[aria-current="page"]::before {
    content: "";
    position: absolute;
    left: 0;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 0 4px 4px 0;
    background: var(--brand-purple-light);
}

/* Los enlaces de acción son <button>: igualar al look de los <a> del menú */
button.side-menu-link {
    width: 100%;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    text-align: left;
}
/* Botón de Google: destacado con su color de marca */
.side-menu-link--google {
    background: linear-gradient(90deg, rgba(66, 133, 244, 0.16), rgba(66, 133, 244, 0.03));
    color: var(--text-color);
}
.side-menu-link--google i { color: #4285F4; opacity: 1; }
.side-menu-link--google:hover {
    background: linear-gradient(90deg, rgba(66, 133, 244, 0.26), rgba(66, 133, 244, 0.06));
}
/* Borrar cuenta: tono de alarma */
.side-menu-link--danger { color: #F87171; }
.side-menu-link--danger i { color: #F87171; }
.side-menu-link--danger:hover {
    background: linear-gradient(90deg, rgba(248, 113, 113, 0.18), rgba(248, 113, 113, 0.03));
    color: #FCA5A5;
}

/* --- Los 10 perros difuminados como decoración de fondo del menú ---
   Rejilla 2 columnas × 5 filas: reparte los perros por todo el menú y
   GARANTIZA que ninguno se solape con otro (cada uno en su celda). */
.side-menu-dogs-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;            /* detrás del contenido del menú */

    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(5, 1fr);
    place-items: center;
    padding: 14px;
    gap: 8px;
}
.menu-dog-bg {
    width: 100%;
    max-width: 120px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    object-fit: cover;
    opacity: 0.17;          /* semitransparente */
    filter: blur(2px);      /* difuminado */
    -webkit-mask-image: radial-gradient(circle, #000 58%, transparent 80%);
            mask-image: radial-gradient(circle, #000 58%, transparent 80%);
}

/* El contenido del menú va por encima de la decoración */
.side-menu-header,
.side-menu-content { position: relative; z-index: 1; }

/* Entrada escalonada de los enlaces al abrir el menú */
@keyframes menuLinkIn {
    from { opacity: 0; transform: translateX(-12px); }
    to   { opacity: 1; transform: translateX(0); }
}
body.side-menu-open .side-menu-link { animation: menuLinkIn 0.32s ease both; }
body.side-menu-open .side-menu-link:nth-child(1) { animation-delay: 0.04s; }
body.side-menu-open .side-menu-link:nth-child(2) { animation-delay: 0.08s; }
body.side-menu-open .side-menu-link:nth-child(3) { animation-delay: 0.12s; }
body.side-menu-open .side-menu-link:nth-child(4) { animation-delay: 0.16s; }
body.side-menu-open .side-menu-link:nth-child(5) { animation-delay: 0.20s; }
body.side-menu-open .side-menu-link:nth-child(6) { animation-delay: 0.24s; }

/* --- Overlay translúcido --- */
#menu-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
    z-index: 150;
}
body.side-menu-open #menu-overlay {
    opacity: 1;
    pointer-events: auto;
}

/* --- Responsive (tablet+) --- */
@media (min-width: 768px) {
    :root { --header-height: 68px; --side-menu-width: 320px; }
    #app-header { padding: env(safe-area-inset-top) 24px 0; gap: 20px; }
    .app-title__text { font-size: 1.4rem; }
    .app-logo { width: 34px; height: 34px; border-radius: 10px; }
    .app-logo svg { width: 19px; height: 19px; }
    .header-icons { gap: 8px; }
    .icon-btn { width: 44px; height: 44px; }
    .header-svg { width: 24px; height: 24px; }
    .side-menu-header { padding: 0 14px 0 32px; }
    .side-menu-content { padding: 32px; }
}

/* =============================================================================
   LLAMA CON NIVELES 🔥 — la racha se ve crecer
   ≥7 días: llama más grande que chisporrotea · ≥30 días: llama AZUL
   ========================================================================== */
/* Nivel 2 (una semana): crece y suelta chispas al estar encendida */
.streak-badge--lv2 .streak-badge__flame {
    width: 22px;
    height: 22px;
}
.streak-badge--lv2 { position: relative; }
.streak-badge--lv2.streak-badge--lit::before {
    content: "";
    position: absolute;
    left: 10px; top: -2px;
    width: 16px; height: 14px;
    pointer-events: none;
    background:
        radial-gradient(circle, #ffd36b 45%, transparent 55%) 15% 100% / 3px 3px no-repeat,
        radial-gradient(circle, #ff9600 45%, transparent 55%) 60% 100% / 2.5px 2.5px no-repeat,
        radial-gradient(circle, #ffd36b 45%, transparent 55%) 90% 100% / 2px 2px no-repeat;
    animation: streak-sparks 1.4s ease-in infinite;
}
@keyframes streak-sparks {
    0%   { transform: translateY(2px);   opacity: 0; }
    25%  { opacity: 1; }
    100% { transform: translateY(-10px); opacity: 0; }
}
/* Nivel 3 (un mes): fuego AZUL — el fuego más caliente que existe */
.streak-badge--lv3.streak-badge--lit .streak-badge__flame {
    fill: #3fa9ff;
    filter: drop-shadow(0 0 7px rgba(60, 150, 255, 0.65));
}
.streak-badge--lv3.streak-badge--lit .streak-badge__num { color: #7cc4ff; }
.streak-badge--lv3.streak-badge--lit::before {
    background:
        radial-gradient(circle, #9ed4ff 45%, transparent 55%) 15% 100% / 3px 3px no-repeat,
        radial-gradient(circle, #3fa9ff 45%, transparent 55%) 60% 100% / 2.5px 2.5px no-repeat,
        radial-gradient(circle, #9ed4ff 45%, transparent 55%) 90% 100% / 2px 2px no-repeat;
}
@media (prefers-reduced-motion: reduce) {
    .streak-badge--lv2.streak-badge--lit::before { animation: none; opacity: 0.6; }
}
body.pa-battery-saver .streak-badge--lv2.streak-badge--lit::before { animation: none; opacity: 0; }

/* ARO DE RACHA 🔥 en el avatar del perfil: si hoy ya practicaste, el circulito
   luce anillo naranja degradado (tipo "stories") — se enciende desde streak.js */
.profile-btn.streak-ring {
    box-shadow:
        0 0 0 2px rgba(255, 150, 0, 0.9),
        0 0 10px rgba(255, 130, 0, 0.45);
    border-radius: 50%;
}
/* Sin mascota aún no hay aro de racha: sobre el hueco punteado parecía
   un adorno roto (pantallazo de Axel, 16-jul). Vuelve al elegir avatar. */
.profile-btn:not(.profile-btn--has-avatar).streak-ring {
    box-shadow: none;
}

/* =============================================================================
   MENÚ LATERAL v2 — tu rincón: tarjeta de cuenta + grupos + pie discreto
   ========================================================================== */
/* El contenido ocupa todo el alto para poder anclar el pie abajo */
.side-menu-content {
    display: flex;
    flex-direction: column;
    height: calc(100% - 70px);   /* deja sitio a la cabecera del menú */
}

/* Tarjeta de CUENTA: avatar del perro + nombre + correo + racha */
.side-menu-acct {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px;
    margin-bottom: 18px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(255, 255, 255, 0.05));
    color: #fff;
    text-align: left;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.25s ease;
}
.side-menu-acct:hover  { border-color: rgba(184, 148, 255, 0.55); }
.side-menu-acct:active { transform: scale(0.98); }
.side-menu-acct__avatar {
    flex: 0 0 auto;
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 1.4rem;
    background: rgba(255, 255, 255, 0.10);
    overflow: hidden;
}
.side-menu-acct__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.side-menu-acct__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.side-menu-acct__text strong {
    font-size: 1rem;
    font-weight: 900;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.side-menu-acct__text small {
    font-size: 0.74rem;
    color: rgba(255, 255, 255, 0.55);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.side-menu-acct__streak { color: #ffb13d !important; font-weight: 800; }

/* Titulito de grupo ("Ayuda") */
.side-menu-group {
    margin: 4px 6px 6px;
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.35);
}

/* Pie del menú: borrar cuenta (discreto) + versión */
.side-menu-foot {
    margin-top: auto;            /* empuja el pie al fondo */
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}
.side-menu-delete {
    border: none;
    background: none;
    padding: 6px 8px;
    font-size: 0.78rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.35);   /* gris hasta que lo buscas */
    cursor: pointer;
    border-radius: 8px;
    transition: color 0.2s ease, background 0.2s ease;
}
.side-menu-delete:hover {
    color: #FCA5A5;
    background: rgba(248, 113, 113, 0.12);
}
.side-menu-version {
    padding: 0 8px 4px;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.28);
}

/* Los perritos del fondo, un punto más presentes (guiño visible) */
.menu-dog-bg {
    opacity: 0.26;
    filter: blur(1.5px);
}

/* =============================================================================
   🎯 ANILLO DE LA META (goal-ring.js) — junto al título, estilo reloj deportivo
   ========================================================================== */
.goal-ring {
    position: relative;
    width: 24px; height: 24px;
    margin-left: 6px;
    flex-shrink: 0;
}
.goal-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.goal-ring__bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.18);
    stroke-width: 3;
}
.goal-ring__arc {
    fill: none;
    stroke: #C4B5FD;
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dashoffset 600ms ease;
}
.goal-ring__num {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.56rem; font-weight: 900;
    color: rgba(255, 255, 255, 0.85);
}
/* META CUMPLIDA: anillo dorado con destello y ✓ */
.goal-ring--done .goal-ring__arc { stroke: #FBBF24; }
.goal-ring--done .goal-ring__num { color: #FBBF24; }
.goal-ring--done { animation: goalRingDone 700ms cubic-bezier(0.3, 1.5, 0.4, 1); }
@keyframes goalRingDone {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.35); }
    100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
    .goal-ring--done { animation: none; }
    .goal-ring__arc { transition: none; }
}
