/* calendar-public.css — CalendarPublic.aspx, styled to match
   econApp/CALENDAR/econDeptTracking/Public.aspx (FullCalendar glass shell). */

:root {
    --brand: #5b2a6b;
    --brand-soft: #f3edf5;
    --ink: #1d1d1f;
    --muted: #6e6e73;
    --line: rgba(29, 29, 31, .09);
    --surface: #fff;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { position: relative; background: #d9d9dc; color: var(--ink); font-family: 'Anuphan', system-ui, sans-serif; }
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image: url('/images/Background/image%20(2).jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: grayscale(1) brightness(.9) contrast(1.05);
}
.public-calendar-page { min-height: 100vh; min-height: 100dvh; }
.calendar-main { height: 100vh; height: 100dvh; padding: 16px; overflow: hidden; }
.calendar-shell { height: 100%; min-height: 0; margin: 0; padding: 20px; display: flex; flex-direction: column; gap: 16px; background: rgba(255,255,255,.5); border: 1px solid rgba(255,255,255,.6); border-radius: 28px; box-shadow: 0 18px 60px rgba(29,29,31,.12); backdrop-filter: blur(22px) saturate(160%); -webkit-backdrop-filter: blur(22px) saturate(160%); }
.calendar-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex: 0 0 auto; }
.calendar-heading-left { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1 1 auto; }
.calendar-heading-copy { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; }
.calendar-heading-icon { width: 20px; height: 20px; color: var(--brand); flex-shrink: 0; }
.calendar-heading-text { min-width: 0; }
.calendar-heading h1 { margin: 0; font-size: clamp(17px, 1.4vw, 22px); font-weight: 650; letter-spacing: -.03em; line-height: 1.2; }
.calendar-heading p { margin: 2px 0 0; font-size: 10px; line-height: 1.3; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calendar-heading-desc { color: var(--ink); font-weight: 500; }
.calendar-heading-hint { color: #9A5B2E; }
.calendar-header-actions { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.calendar-toolbar { display: flex; align-items: center; gap: 7px; }
.calendar-icon-btn { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--brand); cursor: pointer; }
.calendar-icon-btn:hover { background: var(--brand-soft); }
.calendar-icon-btn svg { width: 16px; }
.calendar-subscribe { position: relative; flex: 0 0 auto; }
.calendar-subscribe-menu { position: absolute; top: calc(100% + 8px); right: 0; width: 340px; background: rgba(255,255,255,.92); border: 1px solid rgba(255,255,255,.6); border-radius: 16px; box-shadow: 0 16px 40px rgba(0,0,0,.18); padding: 12px; z-index: 40; backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%); }
.calendar-subscribe-menu[hidden] { display: none; }
.calendar-subscribe-item { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 10px; text-decoration: none; color: var(--ink); font-size: 12.5px; font-weight: 600; transition: background .15s; }
.calendar-subscribe-item:hover { background: var(--brand-soft); }
.calendar-subscribe-item svg { width: 15px; height: 15px; color: var(--brand); flex-shrink: 0; }
.calendar-subscribe-label { margin: 10px 2px 6px; font-size: 10.5px; font-weight: 600; color: var(--muted); }
.calendar-subscribe-copy { display: flex; flex-direction: column; gap: 8px; margin: 0 0 6px; }
.calendar-subscribe-input { width: 100%; resize: none; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.8); font-family: 'Consolas', 'SFMono-Regular', monospace; font-size: 11px; line-height: 1.5; color: var(--ink); word-break: break-all; white-space: pre-wrap; }
.calendar-subscribe-copy-btn { width: 100%; padding: 9px 12px; border: 0; border-radius: 10px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s; }
.calendar-subscribe-copy-btn.is-copied { background: #34C759; }
.calendar-subscribe-hint { margin: 4px 2px 2px; font-size: 10px; line-height: 1.5; color: var(--muted); }
.calendar-title-wrap { width: 150px; text-align: center; line-height: 1.15; }
.calendar-title-wrap h2 { margin: 0; font-size: 15px; font-weight: 650; }
.calendar-title-wrap span { color: var(--muted); font-size: 10px; }
.calendar-views { display: flex; padding: 3px; border-radius: 11px; background: #f0f0f2; }
.calendar-view-btn { padding: 6px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; }
.calendar-view-btn.is-active { background: #fff; color: var(--ink); box-shadow: 0 1px 5px rgba(0,0,0,.1); }
.calendar-today-btn { padding: 7px 16px; border: 0; border-radius: 999px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 600; cursor: pointer; }
.calendar-body { display: flex; gap: 16px; flex: 1 1 auto; min-height: 0; }
.calendar-canvas { min-height: 0; flex: 1 1 78%; min-width: 0; }
#calendarEl, .fc { height: 100%; }
.fc { font-family: inherit; font-size: 13px; }
.fc-theme-standard .fc-scrollgrid { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.4); backdrop-filter: blur(16px) saturate(160%); -webkit-backdrop-filter: blur(16px) saturate(160%); }
.fc-theme-standard td, .fc-theme-standard th { border-color: var(--line); }
.fc .fc-col-header-cell { padding: 8px 0; background: rgba(255,255,255,.25); border: 0; }
.fc .fc-col-header-cell-cushion { color: var(--muted); font-size: 11px; font-weight: 650; text-decoration: none; }
.fc .fc-daygrid-day { background: transparent; }
.fc .fc-daygrid-day:hover { background: rgba(255,255,255,.3); }
.fc .fc-day-today { background: rgba(255,255,255,.22) !important; }
.fc .fc-daygrid-day-number { width: 27px; height: 27px; margin: 3px; padding: 0; display: grid; place-items: center; border-radius: 50%; color: var(--ink); font-size: 12px; text-decoration: none; }
.fc .fc-day-today .fc-daygrid-day-number { background: var(--brand); color: #fff; }
.fc .fc-event { margin: 1px 4px; padding: 2px 5px; border: 0; border-left: 3px solid; border-radius: 5px; cursor: pointer; }
.fc .fc-event-main, .fc .fc-event-title, .fc .fc-event-time { color: var(--ink); font-size: 11px; }
.fc .fc-list { border-color: var(--line); border-radius: 16px; overflow: hidden; }
.fc .fc-list-event:hover td { background: #faf8fb; }

.calendar-status { padding: 9px 12px; border-radius: 10px; background: #fff1f0; color: #b42318; font-size: 12px; }

/* Timeline sidebar — upcoming events, mirrors the homepage department calendar */
.calendar-timeline-card { flex: 0 0 280px; display: flex; flex-direction: column; min-height: 0; background: rgba(255,255,255,.4); border: 1px solid rgba(255,255,255,.55); border-radius: 18px; padding: 18px 16px; overflow: hidden; backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%); }
.calendar-timeline-header { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.calendar-timeline-header svg { width: 16px; height: 16px; color: var(--brand); }
.calendar-timeline { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0; }
.calendar-tl-item { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(0,0,0,.05); }
.calendar-tl-item:last-child { border-bottom: none; }
.calendar-tl-line { width: 3px; border-radius: 2px; align-self: stretch; min-height: 34px; flex-shrink: 0; }
.calendar-tl-date { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 38px; flex-shrink: 0; padding: 4px 2px; border-radius: 10px; background: #f5f5f7; }
.calendar-tl-day { font-size: 18px; font-weight: 700; color: var(--ink); line-height: 1; }
.calendar-tl-month { font-size: 9.5px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.calendar-tl-content { flex: 1; min-width: 0; }
.calendar-tl-title { font-size: 12.5px; font-weight: 600; color: var(--ink); line-height: 1.35; word-break: break-word; }
.calendar-tl-time { display: flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 400; color: var(--muted); margin-top: 3px; }
.calendar-tl-icon { width: 10px; height: 10px; }
.calendar-tl-empty { text-align: center; padding: 20px 0; font-size: 12px; color: var(--muted); }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 8px 12px; flex: 0 0 auto; padding-top: 14px; margin-top: 4px; border-top: 1px solid var(--line); }
.calendar-legend-item { display: flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 500; color: var(--muted); }
.calendar-legend-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* Hover popover — quick peek like the homepage department calendar */
.pcal-ev-popover {
    position: fixed;
    z-index: 9999;
    max-width: 320px;
    background: rgba(255,255,255,.55);
    backdrop-filter: blur(26px) saturate(180%);
    -webkit-backdrop-filter: blur(26px) saturate(180%);
    border: 1px solid rgba(255,255,255,.55);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0,0,0,.16), inset 0 1px 0 rgba(255,255,255,.7);
    padding: 14px 16px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px) scale(.96);
    transition: opacity .22s cubic-bezier(.16,1,.3,1), transform .22s cubic-bezier(.16,1,.3,1);
    will-change: opacity, transform;
}
.pcal-ev-popover.is-visible { opacity: 1; transform: translateY(0) scale(1); }
.pcal-pop-title { font-size: 13.5px; font-weight: 700; color: var(--ink); line-height: 1.4; margin-bottom: 8px; overflow-wrap: anywhere; word-break: break-word; }
.pcal-pop-row { display: flex; align-items: flex-start; gap: 6px; font-size: 12px; font-weight: 500; color: #48484a; margin-bottom: 4px; overflow-wrap: anywhere; word-break: break-word; }
.pcal-pop-row:last-of-type { margin-bottom: 0; }
.pcal-pop-icon { width: 13px; height: 13px; color: var(--muted); flex-shrink: 0; margin-top: 1px; }
.pcal-pop-tag { display: inline-block; margin-top: 10px; font-size: 10.5px; font-weight: 600; color: #fff; padding: 2px 8px; border-radius: 20px; }

.event-detail-backdrop { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 20px; background: rgba(20,17,21,.35); backdrop-filter: blur(8px); }
.event-detail-backdrop[hidden] { display: none; }
.event-detail-card { position: relative; width: min(640px, 100%); overflow: hidden; border-radius: 24px; background: rgba(255,255,255,.85); border: 1px solid rgba(255,255,255,.85); backdrop-filter: blur(28px) saturate(130%); -webkit-backdrop-filter: blur(28px) saturate(130%); box-shadow: 0 24px 80px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.85); }
.event-detail-stripe { height: 8px; background: var(--brand); }
.event-detail-close { position: absolute; top: 22px; right: 20px; width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(242,242,244,.6); backdrop-filter: blur(10px); cursor: pointer; }
.event-detail-close svg { width: 17px; }
.event-detail-content { padding: 30px; }
.event-detail-category { display: inline-block; margin-bottom: 9px; color: var(--brand); font-size: 11px; font-weight: 700; }
.event-detail-content h2 { margin: 0 42px 20px 0; font-size: 23px; line-height: 1.35; }
.event-detail-meta { display: flex; gap: 9px; align-items: flex-start; margin: 9px 0; color: var(--muted); font-size: 13px; }
.event-detail-meta svg { width: 16px; flex: 0 0 auto; }
.event-detail-content p { margin: 20px 0 0; padding-top: 18px; border-top: 1px solid var(--line); color: #48484a; font-size: 13px; line-height: 1.7; white-space: pre-wrap; }

@media (max-width: 1050px) {
    .calendar-main { height: auto; min-height: 100vh; min-height: 100dvh; padding: 16px; overflow: visible; }
    .calendar-shell { min-height: calc(100vh - 32px); }
    .calendar-heading { align-items: flex-start; flex-direction: column; }
    .calendar-heading-left, .calendar-header-actions { width: 100%; }
    .calendar-header-actions { align-items: flex-start; }
    .calendar-toolbar { flex: 1 1 auto; min-width: 0; }
    .calendar-toolbar { width: 100%; flex-wrap: wrap; }
    .calendar-body { flex: 0 0 auto; flex-direction: column; }
    .calendar-canvas { min-height: 0; flex: 0 0 auto; }
    #calendarEl, .fc { height: auto; }
    .calendar-timeline-card { flex: 0 0 auto; max-height: 340px; }
}

@media (max-width: 820px) {
    .calendar-heading-copy { align-items: flex-start; }
    .calendar-heading p { white-space: normal; overflow: visible; text-overflow: clip; }
    .calendar-header-actions { gap: 10px; }
    .calendar-title-wrap { flex: 1 1 150px; width: auto; min-width: 130px; }
    .calendar-views { order: 2; width: 100%; }
    .calendar-view-btn { flex: 1; min-height: 36px; }
    .calendar-icon-btn { width: 40px; height: 40px; flex: 0 0 40px; }
    .calendar-today-btn { min-height: 40px; padding-inline: 20px; }
}

@media (max-width: 640px) {
    .calendar-main { padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
    .calendar-shell { min-height: calc(100dvh - 16px); padding: 12px; gap: 12px; border-radius: 18px; }
    .calendar-heading { gap: 12px; }
    .calendar-heading-left { gap: 8px; }
    .calendar-heading-copy { gap: 8px; }
    .calendar-heading-icon { display: none; }
    .calendar-heading h1 { font-size: 17px; line-height: 1.35; }
    .calendar-heading p { display: none; }
    .calendar-header-actions { position: relative; padding-right: 48px; }
    .calendar-toolbar { gap: 6px; }
    .calendar-subscribe { position: absolute; top: 0; right: 0; }
    .calendar-subscribe-menu { position: fixed; top: auto; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); left: 8px; width: auto; max-height: calc(100dvh - 16px); overflow-y: auto; }
    .calendar-title-wrap { order: 0; flex: 1 1 calc(100% - 132px); min-width: 0; }
    .calendar-title-wrap h2 { font-size: 14px; }
    .calendar-toolbar > #btnPrev { order: 0; }
    .calendar-toolbar > #btnNext { order: 0; }
    .calendar-toolbar > #btnToday { order: 1; flex: 1; }
    .calendar-views { order: 2; }
    .calendar-canvas { min-height: 0; }
    .calendar-timeline-card { max-height: 360px; padding: 14px 12px; }
    .calendar-legend { gap: 8px 10px; }
    .fc .fc-toolbar-title { font-size: 16px; }
    .fc .fc-list-event-title { font-size: 12px; }
    .fc .fc-list-event-time { font-size: 11px; white-space: normal; }
    .event-detail-backdrop { padding: 10px; align-items: end; }
    .event-detail-card { max-height: calc(100dvh - 20px); overflow-y: auto; border-radius: 20px; }
    .event-detail-content { padding: 24px 20px; }
    .event-detail-content h2 { margin-bottom: 16px; font-size: 19px; }
}

@media (max-width: 390px) {
    .calendar-title-wrap { flex-basis: calc(100% - 92px); }
    .calendar-title-wrap span { display: none; }
    .calendar-icon-btn { width: 38px; height: 38px; flex-basis: 38px; }
    .calendar-today-btn { min-height: 38px; }
    .calendar-canvas { min-height: 0; }
}

@media (hover: none), (pointer: coarse) {
    .calendar-icon-btn:hover { background: #fff; }
    .pcal-ev-popover { display: none; }
}
