/* ═══════════════════════════════════════════════════
   Calendar & Activities — Community Module
   Full-width layout with responsive mobile support
   ═══════════════════════════════════════════════════ */

.calendar-page {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0 0 40px;
}

/* ── Page Header ─────────────────────────────── */
.cal-page-header {
    margin-bottom: 24px;
}
.cal-page-title {
    font-size: 26px;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary, #f1f1f1);
}
.cal-page-subtitle {
    font-size: 14px;
    color: var(--text-secondary, #888);
    margin: 6px 0 0;
}

/* ── Scope Tabs ──────────────────────────────── */
.cal-scope-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    background: var(--card-bg, #1a1a2e);
    border: 1px solid var(--border, rgba(255,255,255,.08));
    border-radius: 14px;
    padding: 5px;
}
.cal-scope-tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #888);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 11px;
    transition: all .2s;
}
.cal-scope-tab:hover {
    color: var(--text-primary, #f1f1f1);
    background: rgba(124,58,237,.06);
}
.cal-scope-tab.active {
    background: var(--accent, #7c3aed);
    color: #fff;
    box-shadow: 0 2px 10px rgba(124,58,237,.3);
}

/* ── Legend ───────────────────────────────────── */
.cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-bottom: 20px;
    padding: 12px 18px;
    background: var(--card-bg, #1a1a2e);
    border: 1px solid var(--border, rgba(255,255,255,.08));
    border-radius: 12px;
}
.cal-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary, #888);
}
.cal-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Calendar Container ──────────────────────── */
.cal-container {
    background: var(--card-bg, #1a1a2e);
    border: 1px solid var(--border, rgba(255,255,255,.08));
    border-radius: 18px;
    padding: 28px;
    margin-bottom: 20px;
}

/* ── Calendar Nav ────────────────────────────── */
.cal-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
}
.cal-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border, rgba(255,255,255,.08));
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary, #888);
    cursor: pointer;
    transition: all .15s;
}
.cal-nav-btn:hover {
    background: rgba(124,58,237,.1);
    color: var(--accent, #7c3aed);
    border-color: rgba(124,58,237,.2);
}
.cal-nav-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 200px;
    justify-content: center;
}
.cal-month-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary, #f1f1f1);
}
.cal-year {
    font-size: 18px;
    color: var(--text-secondary, #888);
    font-weight: 400;
}
.cal-today-btn {
    padding: 8px 18px;
    border: 1px solid rgba(124,58,237,.25);
    border-radius: 8px;
    background: rgba(124,58,237,.08);
    color: var(--accent, #7c3aed);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
}
.cal-today-btn:hover {
    background: rgba(124,58,237,.18);
}

/* ── Calendar Grid ───────────────────────────── */
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.cal-weekdays {
    margin-bottom: 8px;
}
.cal-weekday {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-secondary, #888);
    padding: 10px 0;
}

/* ── Calendar Day Cell ───────────────────────── */
.cal-day {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100px;
    padding: 10px 6px 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: all .15s;
    border: 1px solid transparent;
}
.cal-day:hover {
    background: rgba(124,58,237,.06);
    border-color: rgba(124,58,237,.12);
}
.cal-day.other-month {
    opacity: .25;
    cursor: default;
}
.cal-day.other-month:hover {
    background: transparent;
    border-color: transparent;
}

.cal-day-num {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary, #f1f1f1);
    line-height: 1;
}

.cal-day.today .cal-day-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: var(--accent, #7c3aed);
    color: #fff;
    border-radius: 50%;
    font-weight: 700;
}

.cal-day.selected {
    background: rgba(124,58,237,.1);
    border-color: var(--accent, #7c3aed);
}

.cal-day.has-events {
    background: rgba(124,58,237,.04);
}

/* Event dots under day number */
.cal-day-dots {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    margin-top: 8px;
}
.cal-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Event count badge */
.cal-day-count {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--accent, #7c3aed);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 0 5px;
}

/* ═══════════════════════════════════════════════
   Detail Panel
   ═══════════════════════════════════════════════ */
.cal-detail-panel {
    background: var(--card-bg, #1a1a2e);
    border: 1px solid var(--border, rgba(255,255,255,.08));
    border-radius: 18px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height .3s ease, opacity .3s ease, padding .3s ease;
    padding: 0 24px;
}
.cal-detail-panel.open {
    max-height: 700px;
    opacity: 1;
    padding: 24px;
}

.cal-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}
.cal-detail-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #f1f1f1);
}
.cal-detail-close {
    width: 34px;
    height: 34px;
    border: none;
    background: rgba(255,255,255,.06);
    border-radius: 8px;
    font-size: 20px;
    color: var(--text-secondary, #888);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.cal-detail-close:hover {
    background: rgba(239,68,68,.12);
    color: #ef4444;
}

.cal-detail-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 500px;
    overflow-y: auto;
}

.cal-detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 0;
    color: var(--text-secondary, #888);
    text-align: center;
}
.cal-detail-empty svg { opacity: .35; }
.cal-detail-empty p { margin: 0; font-size: 15px; }

/* ── Event Card ──────────────────────────────── */
.cal-event-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(255,255,255,.03);
    border: 1px solid var(--border, rgba(255,255,255,.06));
    text-decoration: none;
    color: inherit;
    transition: all .15s;
    position: relative;
    overflow: hidden;
}
.cal-event-card:hover {
    background: rgba(124,58,237,.06);
    border-color: rgba(124,58,237,.15);
    transform: translateX(2px);
}

.ev-color-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--ev-color, #7c3aed);
    border-radius: 4px 0 0 4px;
}

.ev-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--ev-color, #7c3aed) 12%, transparent);
    color: var(--ev-color, #7c3aed);
    flex-shrink: 0;
}

.ev-info {
    flex: 1;
    min-width: 0;
}
.ev-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #f1f1f1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ev-subtitle {
    font-size: 13px;
    color: var(--text-secondary, #888);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ev-time {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent, #7c3aed);
    white-space: nowrap;
    background: rgba(124,58,237,.08);
    padding: 5px 10px;
    border-radius: 6px;
}

.ev-type-badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--ev-color, #7c3aed);
    white-space: nowrap;
    padding: 4px 10px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--ev-color, #7c3aed) 10%, transparent);
}

/* ═══════════════════════════════════════════════
   Light Theme
   ═══════════════════════════════════════════════ */
[data-theme="light"] .cal-page-title { color: #1f2937; }
[data-theme="light"] .cal-page-subtitle { color: #6b7280; }
[data-theme="light"] .cal-container { background: #fff; border-color: #e5e7eb; }
[data-theme="light"] .cal-scope-tabs { background: #fff; border-color: #e5e7eb; }
[data-theme="light"] .cal-scope-tab { color: #6b7280; }
[data-theme="light"] .cal-scope-tab:hover { color: #1f2937; background: #f3f4f6; }
[data-theme="light"] .cal-scope-tab.active { background: var(--accent, #7c3aed); color: #fff; }
[data-theme="light"] .cal-legend { background: #fff; border-color: #e5e7eb; }
[data-theme="light"] .cal-legend-item { color: #6b7280; }
[data-theme="light"] .cal-month-name { color: #1f2937; }
[data-theme="light"] .cal-year { color: #6b7280; }
[data-theme="light"] .cal-nav-btn { border-color: #e5e7eb; color: #6b7280; }
[data-theme="light"] .cal-day-num { color: #1f2937; }
[data-theme="light"] .cal-day:hover { background: #f3f4f6; border-color: #e5e7eb; }
[data-theme="light"] .cal-day.selected { background: rgba(124,58,237,.08); }
[data-theme="light"] .cal-detail-panel { background: #fff; border-color: #e5e7eb; }
[data-theme="light"] .cal-detail-header h3 { color: #1f2937; }
[data-theme="light"] .cal-detail-close { background: #f3f4f6; }
[data-theme="light"] .cal-event-card { background: #fafafa; border-color: #e5e7eb; }
[data-theme="light"] .cal-event-card:hover { background: #f0f0ff; }
[data-theme="light"] .ev-title { color: #1f2937; }
[data-theme="light"] .ev-subtitle { color: #6b7280; }

/* ═══════════════════════════════════════════════
   Responsive — Tablet
   ═══════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .cal-container { padding: 20px; }
    .cal-day { min-height: 85px; }
    .cal-day-num { font-size: 15px; }
    .cal-day.today .cal-day-num { width: 30px; height: 30px; }
}

/* ═══════════════════════════════════════════════
   Responsive — Mobile
   ═══════════════════════════════════════════════ */
@media (max-width: 768px) {
    .calendar-page { padding: 0 0 24px; }
    .cal-page-title { font-size: 20px; }
    .cal-page-subtitle { font-size: 12px; }
    .cal-container { padding: 14px; border-radius: 14px; }
    .cal-nav { gap: 10px; margin-bottom: 16px; }
    .cal-nav-title { min-width: 150px; }
    .cal-month-name { font-size: 18px; }
    .cal-year { font-size: 15px; }
    .cal-nav-btn { width: 36px; height: 36px; }
    .cal-today-btn { padding: 6px 12px; font-size: 12px; }
    .cal-grid { gap: 4px; }
    .cal-weekday { font-size: 11px; padding: 6px 0; }
    .cal-day { min-height: 60px; padding: 6px 3px 5px; border-radius: 8px; }
    .cal-day-num { font-size: 13px; }
    .cal-day.today .cal-day-num { width: 26px; height: 26px; font-size: 12px; }
    .cal-dot { width: 5px; height: 5px; }
    .cal-day-dots { gap: 3px; margin-top: 5px; }
    .cal-day-count { font-size: 9px; min-width: 16px; height: 16px; top: 3px; right: 3px; }
    .cal-scope-tabs { border-radius: 10px; padding: 3px; }
    .cal-scope-tab { padding: 8px 12px; font-size: 13px; }
    .cal-legend { gap: 10px; padding: 8px 12px; }
    .cal-legend-item { font-size: 11px; }
    .cal-event-card { padding: 10px 12px; gap: 10px; }
    .ev-type-badge { display: none; }
    .cal-detail-panel.open { padding: 16px; }
    .cal-detail-header h3 { font-size: 15px; }
}

/* ═══════════════════════════════════════════════
   Responsive — Small Mobile
   ═══════════════════════════════════════════════ */
@media (max-width: 480px) {
    .cal-page-title { font-size: 18px; }
    .cal-weekday { font-size: 10px; letter-spacing: 0; }
    .cal-day { min-height: 50px; padding: 5px 2px 4px; }
    .cal-day-num { font-size: 12px; }
    .cal-day.today .cal-day-num { width: 24px; height: 24px; }
    .cal-day-dots { margin-top: 4px; }
    .cal-dot { width: 4px; height: 4px; }
    .cal-day-count { font-size: 8px; min-width: 14px; height: 14px; }
    .cal-legend-item { font-size: 10px; gap: 4px; }
    .cal-legend-dot { width: 8px; height: 8px; }
    .cal-scope-tab { font-size: 12px; padding: 7px 8px; gap: 5px; }
    .cal-scope-tab svg { width: 14px; height: 14px; }
    .ev-time { display: none; }
}
