/* ============================================================
   CIRCUMEUS · app.css v1.0
   ============================================================ */

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-tap-highlight-color: transparent; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--pb);
    color: var(--t1);
    min-height: 100dvh;
    overscroll-behavior: none;
}
button { cursor: pointer; font-family: inherit; }
input, textarea { font-family: inherit; }
a { color: var(--au); text-decoration: none; }

/* ── Variables (Modo claro) ─────────────────────────────────── */
:root {
    --pb:  #F2F2F7;   /* page background */
    --cb:  #FFFFFF;   /* card background */
    --t1:  #000000;   /* text primary */
    --t2:  rgba(60,60,67,.65);  /* text secondary */
    --t3:  rgba(60,60,67,.30);  /* text tertiary */
    --sp:  rgba(60,60,67,.12);  /* separator */
    --au:  #BA7517;   /* ámbar principal */
    --al:  #FAEEDA;   /* ámbar claro */
    --at:  #854F0B;   /* ámbar texto */
    --am:  #FAC775;   /* ámbar medio */
    --red: #E24B4A;
    --grn: #25D366;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --tab-h: 82px;
    --header-h: 54px;
}

/* ── Modo oscuro ────────────────────────────────────────────── */
.dark {
    --pb:  #000000;
    --cb:  #1C1C1E;
    --t1:  #FFFFFF;
    --t2:  rgba(235,235,245,.60);
    --t3:  rgba(235,235,245,.25);
    --sp:  rgba(84,84,88,.55);
    --au:  #FAC775;
    --al:  #3A2102;
    --at:  #FAC775;
    --am:  #BA7517;
}

/* ── Shell ──────────────────────────────────────────────────── */
#app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* ── Status bar placeholder ─────────────────────────────────── */
.statusbar {
    height: 44px;
    background: var(--pb);
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 22px 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--t1);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* ── Scroll container ────────────────────────────────────────── */
#scroll-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    padding-bottom: calc(var(--tab-h) + 8px);
    background: var(--pb);
}
#scroll-container::-webkit-scrollbar { display: none; }

/* ── Vistas ─────────────────────────────────────────────────── */
.view { display: none; padding-bottom: 16px; }
.view.active { display: block; }

/* ── Tab bar ─────────────────────────────────────────────────── */
#tabbar {
    height: var(--tab-h);
    background: var(--cb);
    border-top: .5px solid var(--sp);
    display: flex;
    align-items: flex-start;
    padding-top: 8px;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 10;
}
.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 3px 2px;
    cursor: pointer;
    -webkit-user-select: none; user-select: none;
}
.tab-item i   { font-size: 24px; color: var(--t3); transition: color .2s; }
.tab-item span { font-size: 10px; color: var(--t3); transition: color .2s; }
.tab-item.active i,
.tab-item.active span { color: var(--au); }

/* ── Sección header ─────────────────────────────────────────── */
.section-title {
    font-size: 11px;
    color: var(--t2);
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 0 32px;
    margin-bottom: 5px;
    margin-top: 2px;
}
.page-title {
    font-size: 30px;
    font-weight: 700;
    color: var(--t1);
    padding: 0 20px;
    letter-spacing: -.4px;
    line-height: 1.1;
}
.page-subtitle {
    font-size: 13px;
    color: var(--t2);
    padding: 0 20px;
    margin-top: 2px;
    margin-bottom: 12px;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--cb);
    border-radius: var(--radius-md);
    margin: 0 16px 10px;
    overflow: hidden;
}
.card-pad { padding: 14px; }
.card-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: .5px solid var(--sp);
}
.card-row:last-child { border-bottom: none; }

/* ── Pill / Badge ────────────────────────────────────────────── */
.pill {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s, color .2s;
}
.pill-gold  { background: var(--au); color: var(--al); }
.pill-light { background: var(--sp); color: var(--t2); }
.pill-sm    { padding: 2px 10px; font-size: 11px; border-radius: 20px; }
.badge-gold { background: var(--al); color: var(--at); }
.badge-blue { background: #E6F1FB; color: #0C447C; }

/* ── Segmented control ───────────────────────────────────────── */
.segment {
    display: flex;
    background: var(--sp);
    border-radius: 10px;
    padding: 2px;
    margin: 0 16px 10px;
}
.segment-item {
    flex: 1;
    padding: 6px 4px;
    text-align: center;
    font-size: 12px;
    color: var(--t2);
    border-radius: 8px;
    cursor: pointer;
    transition: background .2s, color .2s;
    -webkit-user-select: none; user-select: none;
}
.segment-item.active {
    background: var(--cb);
    color: var(--t1);
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
}

/* ── Progress bar ────────────────────────────────────────────── */
.pbar {
    height: 4px;
    border-radius: 2px;
    background: var(--sp);
    overflow: hidden;
    margin: 6px 0 4px;
}
.pbar-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--au);
    transition: width .4s ease;
}

/* ── Checkbox (Plan de Vida) ────────────────────────────────── */
.pcheck {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1.5px solid var(--sp);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .2s, border-color .2s;
    color: transparent;
}
.pcheck.done {
    background: var(--au);
    border-color: var(--au);
    color: #fff;
}

/* ── Avatar ─────────────────────────────────────────────────── */
.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
    flex-shrink: 0;
    text-transform: uppercase;
}
.avatar-sm {
    width: 36px;
    height: 36px;
    min-width: 36px;
    font-size: 13px;
}

/* ── Toggle switch ───────────────────────────────────────────── */
.toggle {
    width: 48px;
    height: 28px;
    background: var(--sp);
    border-radius: 14px;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .25s;
}
.toggle.on { background: var(--au); }
.toggle::after {
    content: '';
    width: 22px; height: 22px;
    background: #fff;
    border-radius: 50%;
    position: absolute;
    top: 3px; left: 3px;
    transition: left .25s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle.on::after { left: 23px; }

/* ── Liturgical pill ─────────────────────────────────────────── */
.liturgical-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    background: rgba(186,117,23,.1);
    border-radius: 20px;
    margin: 4px 20px 6px;
    width: fit-content;
}
.liturgical-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--au);
    flex-shrink: 0;
}
.liturgical-label {
    font-size: 11px;
    color: var(--au);
    font-weight: 500;
}

/* ── Racha card ──────────────────────────────────────────────── */
.streak-icon {
    width: 50px; height: 50px;
    border-radius: 14px;
    background: rgba(226,75,74,.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Stats 2x2 ───────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 0 16px;
    margin-bottom: 10px;
}
.stat-card {
    background: var(--cb);
    border-radius: var(--radius-md);
    padding: 12px;
}
.stat-value { font-size: 26px; font-weight: 700; color: var(--au); }
.stat-label { font-size: 12px; color: var(--t2); margin-top: 2px; }

/* ── Calendario ──────────────────────────────────────────────── */
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    padding: 10px 14px 8px;
}
.cal-head { text-align: center; font-size: 10px; color: var(--t2); padding: 2px 0; }
.cal-day  { text-align: center; font-size: 11px; padding: 4px 0; border-radius: 5px; }
.cal-g    { background: #C0DD97; color: #27500A; }
.cal-m    { background: var(--al); color: var(--at); }
.cal-r    { background: #F7C1C1; color: #791F1F; }
.cal-t    { background: var(--au); color: var(--al); font-weight: 700; }
.cal-f    { color: var(--t3); }
.cal-legend {
    display: flex;
    gap: 10px;
    padding: 4px 14px 10px;
}
.cal-legend span {
    font-size: 10px;
    color: var(--t2);
    display: flex;
    align-items: center;
    gap: 3px;
}
.cal-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* ── Rosario beads ───────────────────────────────────────────── */
.bead-row {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-bottom: 5px;
}
.bead-label {
    font-size: 9px;
    color: var(--au);
    font-weight: 600;
    width: 16px;
    text-align: right;
    flex-shrink: 0;
}
.bead {
    border-radius: 50%;
    flex-shrink: 0;
    transition: background .2s, border-color .2s, box-shadow .2s;
}
.bead-done    { background: var(--au); border: 1.5px solid var(--au); }
.bead-current { background: var(--al); border: 2px solid var(--au); box-shadow: 0 0 0 2.5px var(--au); }
.bead-empty   { background: transparent; border: 1.5px solid rgba(186,117,23,.28); }
.bead-large   { width: 13px; height: 13px; }
.bead-small   { width: 9px; height: 9px; }

/* ── Estampas ────────────────────────────────────────────────── */
.stamp-card {
    border-radius: var(--radius-md);
    margin: 0 16px 12px;
    overflow: hidden;
    background: var(--cb);
    border: 1.5px solid var(--au);
}
.stamp-img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}
.stamp-img-placeholder {
    width: 100%;
    height: 160px;
    background: var(--al);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.stamp-img-note {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 5px 12px;
    text-align: center;
    font-size: 10px;
    color: var(--at);
}
.stamp-body { padding: 14px; text-align: center; }

/* ── Intenciones ─────────────────────────────────────────────── */
.intention-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: .5px solid var(--sp);
}
.intention-row:last-child { border-bottom: none; }
.intention-text { font-size: 14px; color: var(--t2); line-height: 1.55; }
.pray-btn {
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 20px;
    background: var(--al);
    color: var(--at);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background .2s, color .2s;
    flex-shrink: 0;
}
.pray-btn.prayed { background: var(--au); color: var(--al); }

/* ── Directorio ──────────────────────────────────────────────── */
.member-card {
    background: var(--cb);
    border-radius: var(--radius-md);
    margin: 0 16px 8px;
    overflow: hidden;
}
.member-header { display: flex; align-items: center; gap: 12px; padding: 14px; }
.member-meta {
    border-top: .5px solid var(--sp);
    padding: 10px 14px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.meta-label {
    font-size: 10px;
    color: var(--t3);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 2px;
}
.meta-value { font-size: 13px; color: var(--t1); }

/* ── Botones ─────────────────────────────────────────────────── */
.btn-primary {
    width: 100%;
    padding: 13px;
    background: var(--au);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    color: var(--al);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity .2s;
}
.btn-primary:active { opacity: .75; }
.btn-secondary {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--au);
    background: var(--al);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn-wa {
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 20px;
    background: #25D366;
    color: #fff;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* ── Toast ───────────────────────────────────────────────────── */
#toast {
    position: fixed;
    bottom: calc(var(--tab-h) + 16px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0,0,0,.85);
    color: #fff;
    font-size: 13px;
    padding: 8px 18px;
    border-radius: 20px;
    opacity: 0;
    transition: opacity .25s, transform .25s;
    pointer-events: none;
    z-index: 999;
    white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Login screen ────────────────────────────────────────────── */
#login-screen {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    gap: 24px;
    background: var(--pb);
}
.login-logo {
    font-size: 36px;
    font-weight: 700;
    color: var(--au);
    letter-spacing: -.5px;
}
.login-sub { font-size: 14px; color: var(--t2); margin-top: -16px; }
.form-group { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.form-input {
    width: 100%;
    padding: 13px 16px;
    border: 1.5px solid var(--sp);
    border-radius: var(--radius-sm);
    background: var(--cb);
    color: var(--t1);
    font-size: 16px;
    outline: none;
    transition: border-color .2s;
}
.form-input:focus { border-color: var(--au); }
.form-label { font-size: 12px; color: var(--t2); font-weight: 500; }
.login-error { font-size: 13px; color: var(--red); text-align: center; min-height: 18px; }

/* ── Responsive (web sin chrome móvil) ───────────────────────── */
@media (min-width: 480px) {
    #app {
        border: 1px solid var(--sp);
        border-radius: 40px;
        margin: 20px auto;
        min-height: calc(100dvh - 40px);
        max-height: calc(100dvh - 40px);
        box-shadow: 0 8px 40px rgba(0,0,0,.12);
        overflow: hidden;
    }
    #scroll-container { border-radius: 0 0 40px 40px; }
}

/* ── Utils ───────────────────────────────────────────────────── */
.spacer-sm { height: 8px; }
.spacer-md { height: 14px; }
.text-au   { color: var(--au); }
.text-t2   { color: var(--t2); }
.text-t3   { color: var(--t3); }
.fw-600    { font-weight: 600; }
.fw-700    { font-weight: 700; }
.fs-11     { font-size: 11px; }
.fs-12     { font-size: 12px; }
.fs-13     { font-size: 13px; }
.fs-14     { font-size: 14px; }
.fs-15     { font-size: 15px; }
.italic    { font-style: italic; }
.text-center { text-align: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
