/* ================================================================
   Calanno – Year-view calendar styles
   ================================================================ */

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

html {
    font-family: system-ui, -apple-system, BlinkMacSystemFont,
                 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    color: #1e293b;
    background: #f8fafc;
    -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

/* ── App header ───────────────────────────────────────────────── */
.app-header {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 14px 24px 12px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-row {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.app-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #0f172a;
}

/* Year navigation */
.year-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-btn {
    width: 30px;
    height: 30px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #ffffff;
    color: #475569;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}
.nav-btn:hover { background: #f1f5f9; border-color: #cbd5e1; }

.year-display {
    font-size: 20px;
    font-weight: 700;
    min-width: 56px;
    text-align: center;
    color: #0f172a;
}

.refresh-btn {
    margin-left: auto;
    width: 32px;
    height: 32px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #ffffff;
    color: #475569;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s, transform 0.3s;
}
.refresh-btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
.refresh-btn.spinning { animation: spin 0.8s linear infinite; }

/* Legend */
.legend {
    display: flex;
    gap: 16px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #64748b;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* ── Loading state ────────────────────────────────────────────── */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: #64748b;
    gap: 16px;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading.hidden { display: none; }

/* ── Error / Setup boxes ──────────────────────────────────────── */
.error-box {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 14px 18px;
    margin: 16px 24px 0;
    color: #991b1b;
    font-size: 13px;
    line-height: 1.5;
}

.setup-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 18px 22px;
    margin: 16px 24px 0;
    color: #1e40af;
    font-size: 13px;
    line-height: 1.6;
}
.setup-box strong { font-weight: 600; }
.setup-box code {
    background: #dbeafe;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
}

.hidden { display: none !important; }

/* ── Calendar grid ────────────────────────────────────────────── */
.calendar-wrapper {
    overflow-x: auto;
    padding: 20px 24px 40px;
}

.calendar-grid {
    display: inline-grid;
    /* 1 month-label column + 6 weeks × 7 days = 42 day columns */
    grid-template-columns: 90px repeat(42, 57px);
    gap: 1px;
    background: #cbd5e1;
    border-radius: 8px;
    overflow: hidden;
    /* subtle shadow to lift off the page */
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

/* ── Generic grid cell ────────────────────────────────────────── */
.g-cell {
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
}

/* ── Corner (top-left blank cell) ─────────────────────────────── */
.corner-cell {
    background: #f8fafc;
    position: sticky;
    left: 0;
    z-index: 4;
}

/* ── Day-of-week headers (M T W T F S S × 6 weeks) ───────────── */
.day-header {
    background: #f8fafc;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    padding: 7px 0;
    text-align: center;
    user-select: none;
}
.day-header.weekend {
    background: #fdf8f0;
    color: #92400e;
}
.day-header.week-start {
    box-shadow: -2px 0 0 0 #94a3b8;
}

/* ── Month labels (left column) ───────────────────────────────── */
.month-label {
    background: #f8fafc;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    padding: 0 12px;
    display: flex;
    align-items: center;
    white-space: nowrap;
    position: sticky;
    left: 0;
    z-index: 3;
}

/* ── Day cells ────────────────────────────────────────────────── */
.day-cell {
    min-height: 60px;
    padding: 4px 3px;
    cursor: default;
    transition: background 0.1s;
    position: relative;
    gap: 1px;
}
.day-cell.week-start {
    box-shadow: -2px 0 0 0 #94a3b8;
}

.day-cell:hover { filter: brightness(0.96); }

/* Weekend shading */
.day-cell.weekend { background: #fdf8f0; }

/* Today highlight */
.day-cell.today {
    background: #dbeafe;
    box-shadow: inset 0 0 0 2px #3b82f6;
    z-index: 1;
}
.day-cell.today.weekend {
    background: #dbeafe;
}

/* Non-existent days (e.g. Feb 30) */
.day-cell.empty {
    background: #f1f5f9;
    cursor: default;
}
.day-cell.empty:hover { filter: none; }

/* ── Day number inside each cell ──────────────────────────────── */
.day-num {
    font-size: 10px;
    line-height: 1;
    color: #94a3b8;
    margin-bottom: 2px;
    user-select: none;
    font-weight: 600;
}

/* ── Event bars inside day cells ──────────────────────────────── */
.event-bar {
    width: calc(100% - 6px);
    height: 5px;
    border-radius: 2px;
    flex-shrink: 0;
}

.overflow-count {
    font-size: 8px;
    color: #94a3b8;
    line-height: 1;
    margin-top: 1px;
    user-select: none;
}

/* ── Tooltip ──────────────────────────────────────────────────── */
.tooltip {
    position: fixed;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.12),
                0 2px 8px rgba(0,0,0,0.06);
    z-index: 100;
    max-width: 300px;
    min-width: 160px;
    pointer-events: none;
}

.tooltip-date {
    font-weight: 600;
    font-size: 13px;
    color: #0f172a;
    margin-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 6px;
}

.tooltip-event {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 3px 0;
}

.tooltip-dot {
    width: 8px;
    height: 8px;
    border-radius: 3px;
    flex-shrink: 0;
    margin-top: 3px;
}

.tooltip-text {
    font-size: 12px;
    color: #334155;
    line-height: 1.4;
}

.tooltip-cal {
    font-size: 10px;
    color: #94a3b8;
}

.tooltip-none {
    font-size: 12px;
    color: #94a3b8;
    font-style: italic;
}

/* ── Demo banner ──────────────────────────────────────────────── */
.demo-banner {
    background: #fefce8;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 12px 18px;
    margin: 16px 24px 0;
    color: #92400e;
    font-size: 13px;
    line-height: 1.5;
}

/* ── Responsive tweaks ────────────────────────────────────────── */
@media (max-width: 640px) {
    .app-header { padding: 10px 14px 8px; }
    .calendar-wrapper { padding: 12px 10px 30px; }
    .app-title { font-size: 15px; }
    .year-display { font-size: 17px; }
    .calendar-grid {
        grid-template-columns: 52px repeat(42, 38px);
    }
    .day-cell { min-height: 42px; }
    .month-label { font-size: 10px; padding: 0 4px; }
    .day-header { font-size: 9px; }
}
