/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
    --fer:          #E74C3C;
    --fer-soft:     #FFE0DE;
    --julia:        #8E44AD;
    --julia-soft:   #EDD5FF;
    --both:         #27AE60;
    --both-soft:    #C8F0D8;
    --none:         #7F8C8D;
    --none-soft:    #E4E7E8;
    --festivo:      #C0960C;
    --festivo-soft: #FEF3CD;
    --weekend-bg:   #E8EBF0;
    --weekend-fg:   #9AA3AD;
    --bg:           #F5F7FA;
    --card:         #FFFFFF;
    --text:         #2E4057;
    --muted:        #8494A7;
    --border:       #DDE2EA;
    --shadow:       rgba(46, 64, 87, 0.09);
    --radius:       12px;
    --radius-sm:    7px;
}

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

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.app-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
}

.app-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.75rem;
}

.app-header h1 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.header-controls-REMOVED { display: none; }

.control-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ctrl-label {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 500;
    margin-right: 0.2rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
button {
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all 0.15s ease;
    background: transparent;
    color: var(--muted);
    line-height: 1.4;
}

.filter-btn          { border-color: var(--border); color: var(--muted); }
.filter-btn:hover    { background: var(--bg); }
.filter-btn.active   { background: var(--text); color: #fff; border-color: var(--text); }

.month-select-REMOVED { display: none; }

/* ── Controls bar ────────────────────────────────────────────────────────────── */
.app-top {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    box-shadow: 0 2px 12px var(--shadow);
}

.calendar-controls {
    background: var(--card);
    border-bottom: 2px solid var(--border);
    padding: 0.55rem 0;
}

.controls-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.75rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.controls-filters {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.controls-sep {
    width: 1px;
    height: 1.4rem;
    background: var(--border);
    flex-shrink: 0;
}

.filter-select {
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.28rem 0.65rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    background: var(--card);
    cursor: pointer;
}
.filter-select:focus { outline: 2px solid #4A90D9; outline-offset: 1px; }

/* ── Context menu ────────────────────────────────────────────────────────── */
.ctx-menu {
    position: fixed;
    z-index: 200;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 28px rgba(46, 64, 87, 0.18);
    padding: 0.3rem;
    min-width: 175px;
    user-select: none;
}

.ctx-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    text-align: left;
    transition: background 0.1s;
}
.ctx-item:hover   { background: var(--bg); }
.ctx-item.current { font-weight: 700; }

.ctx-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ctx-check {
    margin-left: auto;
    color: var(--both);
    font-weight: 700;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.app-main {
    padding: 1.5rem 1.75rem 3rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* ── Calendar grid ───────────────────────────────────────────────────────── */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.1rem;
    margin-bottom: 1.5rem;
}
@media (max-width: 900px) { .calendar-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px) { .calendar-grid { grid-template-columns: 1fr; } }

.year-header {
    grid-column: 1 / -1;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0.5rem 0.25rem 0.35rem;
    border-bottom: 2px solid var(--border);
}

/* ── Month card ──────────────────────────────────────────────────────────── */
.month-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 2px 12px var(--shadow);
    overflow: hidden;
}

.month-title {
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text);
    padding: 0.7rem 0.5rem 0.45rem;
    border-bottom: 1px solid var(--border);
}

.dow-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    padding: 0.4rem 0.3rem 0.15rem;
}

.dow {
    text-align: center;
    font-size: 0.67rem;
    font-weight: 600;
    color: var(--muted);
    padding: 0.15rem 0;
}
.dow.weekend { color: var(--weekend-fg); }

/* ── Days grid ───────────────────────────────────────────────────────────── */
.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    padding: 0.3rem;
}

/* ── Day cell ────────────────────────────────────────────────────────────── */
.day-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-radius: 5px;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    min-height: 34px;
    padding-bottom: 3px;
    background: var(--card);
}

@media (hover: hover) and (pointer: fine) {
    .day-cell:not(.blank):hover {
        transform: scale(1.12);
        box-shadow: 0 3px 8px var(--shadow);
        z-index: 2;
        position: relative;
    }
}

.day-cell:focus-visible {
    outline: 2px solid #4A90D9;
    outline-offset: 1px;
}

.day-cell.blank   { background: transparent; cursor: default; }
.day-cell.weekend { background: var(--weekend-bg); }
.day-cell.fer     { background: var(--fer-soft); }
.day-cell.julia   { background: var(--julia-soft); }
.day-cell.both    { background: var(--both-soft); }
.day-cell.none    { background: var(--none-soft); }
.day-cell.festivo { background: var(--festivo-soft); }

.day-num {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text);
    line-height: 1;
}
.day-cell.weekend .day-num { color: var(--weekend-fg); }
.day-cell.fer     .day-num,
.day-cell.julia   .day-num,
.day-cell.both    .day-num,
.day-cell.none    .day-num,
.day-cell.festivo .day-num { font-weight: 700; }

/* ── Indicator dots ──────────────────────────────────────────────────────── */
.dots {
    display: flex;
    gap: 3px;
    align-items: center;
    justify-content: center;
}

.dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.15s, transform 0.15s;
    flex-shrink: 0;
}
.dot.big  { width: 10px; height: 10px; }
.dot.on   { transform: scale(1.1); }
.dot-fer.on   { background: var(--fer); }
.dot-julia.on { background: var(--julia); }

/* ── Flash animation ─────────────────────────────────────────────────────── */
@keyframes cell-flash {
    0%   { filter: brightness(1.4); }
    100% { filter: brightness(1); }
}
.day-cell.flash { animation: cell-flash 0.35s ease-out; }

/* ── Filter dimming ──────────────────────────────────────────────────────── */
body[data-filter="fer"]   .day-cell:not(.weekend):not(.blank):not(.has-fer)   { opacity: 0.22; }
body[data-filter="julia"] .day-cell:not(.weekend):not(.blank):not(.has-julia) { opacity: 0.22; }

/* ── Lists section ───────────────────────────────────────────────────────── */
.lists-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.1rem;
}
@media (max-width: 560px) { .lists-section { grid-template-columns: 1fr; } }

.person-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 2px 12px var(--shadow);
    padding: 1.1rem 1.3rem 1.3rem;
}

.person-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
}

.list-month {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--bg);
    font-size: 0.85rem;
    flex-wrap: wrap;
}
.list-month strong { min-width: 105px; color: var(--text); flex-shrink: 0; }
.list-month span   { color: var(--muted); flex: 1; line-height: 1.5; }
.list-month em     { color: var(--muted); font-size: 0.78rem; font-style: normal; white-space: nowrap; }

.list-total {
    margin-top: 0.8rem;
    font-size: 0.85rem;
    color: var(--muted);
    text-align: right;
}
.list-total strong { color: var(--text); }

.empty-msg {
    color: var(--muted);
    font-size: 0.85rem;
    font-style: italic;
    padding: 0.3rem 0;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .app-header-inner { padding: 0 0.75rem; }
    .app-header h1 { font-size: 0.95rem; }
    .controls-inner { padding: 0.5rem 0.75rem; gap: 0.5rem; }
    .app-main { padding: 1rem 0.75rem 2.5rem; }
    .calendar-grid { gap: 0.75rem; }
}

@media (max-width: 480px) {
    .controls-inner {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Menú contextual como bottom-sheet en móvil */
@media (max-width: 540px) {
    .ctx-menu {
        left:   0 !important;
        right:  0 !important;
        bottom: 0 !important;
        top:    auto !important;
        min-width: 0;
        border-radius: var(--radius) var(--radius) 0 0;
        padding: 0 0.5rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -4px 24px rgba(46, 64, 87, 0.2);
        animation: sheet-up 0.22s ease-out;
    }
    .ctx-menu::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
        margin: 0.6rem auto 0.4rem;
    }
    .ctx-item {
        padding: 0.9rem 1rem;
        font-size: 0.9rem;
    }
}

@keyframes sheet-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
