/* ============================================================
   ROSHANI PUBLIC SCHOOL — ACADEMIC CALENDAR STYLES
   Screen Aesthetics + Strict A4 Landscape Print Engine
   ============================================================ */

/* ---------- Screen Layout & Hero ---------- */
.calendar-hero {
  background: linear-gradient(135deg, var(--secondary-dark) 0%, var(--secondary) 100%);
  color: var(--white);
  padding: var(--space-10) 0 var(--space-8);
  position: relative;
  overflow: hidden;
}

.calendar-hero::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(185, 28, 92, 0.2) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.calendar-hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: 30px;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: var(--space-4);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.calendar-hero__title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: var(--font-bold);
  line-height: 1.15;
  margin-bottom: var(--space-3);

}

.calendar-hero__subtitle {
  font-size: var(--text-base);
  color: var(--text-light);
  max-width: 650px;
  line-height: var(--leading-relaxed);
}

/* ---------- Institutional Header Banner (Above Calendar) ---------- */
.calendar-header-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  padding: 1.25rem 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}

.calendar-header-banner__logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  margin-bottom: 6px;
}

.calendar-header-banner__name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--secondary-dark, #0F2440);
  margin: 0 0 4px 0;
  letter-spacing: 0.5px;
}

.calendar-header-banner__meta {
  font-size: 0.8125rem;
  color: var(--text-secondary, #475569);
  margin: 0 0 8px 0;
  line-height: 1.35;
}

.calendar-header-banner__doc-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.calendar-header-banner__doc-title {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--primary, #B91C5C);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.calendar-header-banner__session {
  display: inline-block;
  background: var(--secondary, #1A365D);
  color: var(--white, #ffffff);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 4px;
}

/* ---------- Toolbar & Controls ---------- */
.calendar-controls-bar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: var(--space-4) 0;
  position: sticky;
  top: 72px;
  z-index: 90;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.03);
}

.controls-bar__wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.calendar-actions-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.btn-print {
  background: var(--primary);
  color: var(--white);
  border: none;
  font-weight: var(--font-semibold);
  box-shadow: 0 2px 8px rgba(185, 28, 92, 0.25);
  transition: all 0.2s ease;
}

.btn-print:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(185, 28, 92, 0.35);
}

.btn-admin {
  background: var(--secondary);
  color: var(--white);
  border: none;
  font-weight: var(--font-medium);
}

.btn-admin:hover {
  background: var(--secondary-light);
}

/* Category Filter Badges */
.filter-pills-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.calendar-filter-btn {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.calendar-filter-btn:hover {
  background: var(--border-light);
  color: var(--secondary);
}

.calendar-filter-btn.is-active {
  background: var(--secondary);
  color: var(--white);
  border-color: var(--secondary);
}

/* Search Bar */
.calendar-search-box {
  position: relative;
  min-width: 220px;
}

.calendar-search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: var(--text-xs);
  background: var(--surface);
  transition: border-color 0.2s;
}

.calendar-search-box input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--white);
}

.calendar-search-box svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

/* ---------- 12 Month Desktop Calendar Grid ---------- */
.calendar-section {
  padding: var(--space-8) 0 var(--space-12);
  background: var(--surface);
}

.months-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
}

@media (max-width: 1200px) {
  .months-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 900px) {
  .months-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 580px) {
  .months-grid {
    grid-template-columns: 1fr;
  }
}

/* Month Card Design */
.month-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.month-card:hover {
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.month-card__header {
  background: var(--secondary);
  color: var(--white);
  padding: 10px 14px;
  text-align: center;
}

.month-card__title {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  letter-spacing: 1px;
  margin: 0;
  color: var(--white);
  text-transform: uppercase;
}

/* Month Table Layout */
.month-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: var(--text-xs);
}

.month-table th {
  background: var(--surface);
  color: var(--text-secondary);
  font-weight: var(--font-semibold);
  font-size: 10px;
  text-align: center;
  padding: 6px 2px;
  border-bottom: 1px solid var(--border);
}

.month-table th.th-sun {
  color: var(--error);
  background: #FEF2F2;
}

.month-table td {
  height: 38px;
  text-align: center;
  vertical-align: top;
  padding: 4px 2px;
  border: 1px solid var(--border-light);
  position: relative;
  background: var(--white);
  transition: background 0.15s;
}

.month-table td.td-empty {
  background: #F8FAFC;
}

.month-table td.td-day {
  cursor: default;
}

.month-table td.td-sunday {
  background: #F8FAFC;
}

.month-table td.td-sunday .day-num {
  color: var(--error);
  font-weight: var(--font-semibold);
}

.month-table td.has-event {
  cursor: pointer;
  font-weight: var(--font-bold);
}

.month-table td.has-event:hover {
  transform: scale(1.04);
  z-index: 5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.month-table td.is-holiday {
  background: #ECFDF5 !important;
}

.month-table td.is-exam {
  background: #FEF3C7 !important;
}

.month-table td.is-filtered-out {
  opacity: 0.25;
}

.day-num {
  display: block;
  font-size: 11px;
  line-height: 1;
  margin-bottom: 2px;
}

.day-markers {
  display: flex;
  justify-content: center;
  gap: 3px;
  margin-top: 2px;
}

.day-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  display: inline-block;
}

/* Category Color Indicators for Cell Highlights */
.evt-cat-holiday { border-left: 3px solid #10B981; }
.evt-cat-national { border-left: 3px solid #EF4444; }
.evt-cat-festival { border-left: 3px solid #F59E0B; }
.evt-cat-exam { border-left: 3px solid #D97706; }
.evt-cat-event { border-left: 3px solid #B91C5C; }
.evt-cat-ptm { border-left: 3px solid #8B5CF6; }
.evt-cat-academic { border-left: 3px solid #0284C7; }
.evt-cat-other { border-left: 3px solid #475569; }

/* ---------- Interactive Events List Section ---------- */
.events-list-section {
  padding: var(--space-10) 0;
  background: var(--white);
  border-top: 1px solid var(--border);
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.section-title-sm {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--secondary);
  margin: 0;
}

.events-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.events-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  text-align: left;
}

.events-table th {
  background: var(--surface);
  color: var(--secondary);
  font-weight: var(--font-bold);
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
}

.events-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}

.events-table tr:hover {
  background: var(--surface-warm);
}

.td-date-badge {
  color: var(--primary);
  white-space: nowrap;
}

.td-weekday {
  color: var(--text-muted);
  font-weight: var(--font-medium);
}

.evt-title-text {
  font-weight: var(--font-semibold);
  color: var(--secondary-dark);
}

.evt-desc-sub {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin: 4px 0 0 0;
}

.category-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: var(--font-semibold);
  white-space: nowrap;
}

.status-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: var(--font-bold);
  text-transform: uppercase;
}

.status-holiday { background: #DCFCE7; color: #15803D; }
.status-exam { background: #FEF3C7; color: #B45309; }
.status-regular { background: #F1F5F9; color: #475569; }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  z-index: 100000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--white);
  width: 100%;
  max-width: 520px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.modal-card__header {
  background: var(--secondary);
  color: var(--white);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-card__title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--white);
}

.modal-card__subtitle {
  margin: 2px 0 0 0;
  font-size: var(--text-xs);
  color: var(--text-light);
}

.modal-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: var(--white);
  font-size: 24px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card__body {
  padding: 20px;
  max-height: 400px;
  overflow-y: auto;
}

.modal-event-item {
  padding: 14px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.modal-event-item__header {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.modal-event-item__title {
  margin: 0 0 4px 0;
  font-size: var(--text-base);
  color: var(--secondary-dark);
}

.modal-event-item__desc {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.modal-card__footer {
  padding: 12px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  text-align: right;
}

/* Admin Portal Modal Styling */
.admin-modal-card {
  background: var(--white);
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.admin-modal-header {
  background: var(--secondary-dark);
  color: var(--white);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-modal-header h2 {
  margin: 0;
  font-size: var(--text-lg);
  color: var(--white);
}

.admin-modal-header p {
  margin: 2px 0 0 0;
  font-size: var(--text-xs);
  color: var(--text-light);
}

.admin-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  font-size: 24px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
}

.admin-modal-toolbar {
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
}

.admin-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.admin-events-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
}

.admin-events-table th, .admin-events-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.admin-events-table th {
  background: var(--surface);
  font-weight: var(--font-bold);
}

.admin-icon-btn {
  border: 1px solid var(--border);
  background: var(--white);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}

.admin-icon-btn:hover {
  background: var(--border-light);
}

/* ============================================================
   RESPONSIVE DESIGN (TABLETS, PHONES & MOBILE SCREENS)
   ============================================================ */

@media (max-width: 992px) {
  .calendar-hero {
    padding: var(--space-8) 0 var(--space-6);
  }
  .calendar-hero__title {
    font-size: 2.2rem;
  }
  .controls-bar__wrapper {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }
  .filter-pills-group {
    overflow-x: auto;
    padding-bottom: 6px;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filter-pills-group::-webkit-scrollbar {
    display: none;
  }
  .calendar-actions-group {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }
  .calendar-search-box {
    flex: 1 1 100%;
    min-width: 100%;
  }
  .btn-print, .btn-admin {
    flex: 1 1 auto;
    text-align: center;
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .calendar-header-banner {
    padding: 1rem 1.25rem;
  }
  .calendar-header-banner__name {
    font-size: 1.15rem;
  }
  .calendar-header-banner__meta {
    font-size: 0.75rem;
  }
  .calendar-header-banner__doc-title {
    font-size: 0.85rem;
  }
  .admin-modal-card {
    width: 95vw;
    max-height: 92vh;
  }
  .admin-modal-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .admin-session-editor {
    flex-direction: column;
    align-items: stretch;
    margin: 12px 14px 0 14px !important;
  }
  .admin-events-table th, .admin-events-table td {
    padding: 8px 6px;
  }
}

@media (max-width: 480px) {
  .calendar-hero__title {
    font-size: 1.75rem;
  }
  .calendar-hero__subtitle {
    font-size: 0.875rem;
  }
  .section-header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .section-title-sm {
    font-size: 1.35rem;
  }
  .month-table th {
    font-size: 9px;
    padding: 4px 1px;
  }
  .month-table td {
    height: 34px;
    padding: 2px 1px;
  }
  .day-num {
    font-size: 10px;
  }
  .calendar-actions-group {
    flex-direction: column;
  }
  .btn-print, .btn-admin {
    width: 100%;
  }
}

/* ============================================================
   STRICT A4 LANDSCAPE PRINT ENGINE (@media print)
   ============================================================ */

#print-academic-calendar-container {
  display: none;
}

@media print {
  @page {
    size: A4 landscape;
    margin: 4mm 6mm;
  }

  html, body {
    width: 297mm;
    height: 210mm;
    margin: 0 !important;
    padding: 0 !important;
    background: #FFFFFF !important;
    color: #000000 !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Hide screen elements */
  header,
  footer,
  .announcement-bar,
  .mobile-nav,
  .mobile-nav__overlay,
  .calendar-hero,
  .about-hero-ref,
  .about-stats-ref,
  .calendar-controls-bar,
  .calendar-section,
  .events-list-section,
  .no-print,
  .modal-backdrop,
  button,
  a.btn {
    display: none !important;
  }

  /* Show Print Only Container */
  #print-academic-calendar-container {
    display: block !important;
    width: 285mm;
    height: 200mm;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-border-box;
  }

  /* Print Official School Header (Centered) */
  .print-official-header {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    border-bottom: 2pt solid #B91C5C !important;
    padding-bottom: 6px !important;
    margin-bottom: 8px !important;
    background: transparent !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  .print-school-logo {
    width: 48px !important;
    height: 48px !important;
    object-fit: contain !important;
    display: block !important;
    margin: 0 auto 3px auto !important;
  }

  .print-school-title {
    font-family: 'Playfair Display', Georgia, serif !important;
    font-size: 16pt !important;
    font-weight: 800 !important;
    color: #1A365D !important;
    line-height: 1.1 !important;
    margin: 0 0 2px 0 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    text-align: center !important;
  }

  .print-school-meta {
    font-size: 7.5pt !important;
    color: #334155 !important;
    margin: 2px 0 4px 0 !important;
    line-height: 1.25 !important;
    text-align: center !important;
  }

  .print-doc-title-row {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
  }

  .print-doc-title {
    font-family: 'Inter', sans-serif !important;
    font-size: 12pt !important;
    font-weight: 800 !important;
    color: #B91C5C !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    margin: 0 !important;
  }

  .print-session-badge {
    display: inline-block !important;
    background: #1A365D !important;
    color: #ffffff !important;
    font-size: 7.5pt !important;
    font-weight: 700 !important;
    padding: 2px 8px !important;
    border-radius: 3px !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* 4x3 Grid Layout for 12 Months */
  .print-months-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px;
    height: 160mm;
    margin-bottom: 4px;
  }

  .print-month-card {
    border: 0.5pt solid #94a3b8;
    border-radius: 2px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #ffffff;
  }

  .print-month-header {
    background: #1A365D !important;
    color: #ffffff !important;
    font-size: 7.5pt;
    font-weight: 700;
    text-align: center;
    padding: 2px 0;
    letter-spacing: 0.5px;
    text-transform: uppercase;
  }

  .print-month-table {
    width: 100%;
    height: 100%;
    border-collapse: collapse;
    table-layout: fixed;
  }

  .print-month-table th {
    font-size: 6pt;
    font-weight: 700;
    text-align: center;
    background: #f1f5f9 !important;
    color: #334155 !important;
    padding: 1px 0;
    border-bottom: 0.5pt solid #cbd5e1;
  }

  .print-month-table th.th-sun {
    color: #dc2626 !important;
    background: #fee2e2 !important;
  }

  .print-month-table td {
    text-align: center;
    vertical-align: middle;
    padding: 1px 0;
    border: 0.25pt solid #e2e8f0;
    font-size: 6.5pt;
  }

  .print-month-table td.print-sunday {
    background: #f8fafc !important;
    color: #dc2626 !important;
    font-weight: 700;
  }

  .print-day-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }

  .print-day-num {
    font-size: 6.5pt;
  }

  .print-evt-code {
    font-size: 4pt;
    font-weight: 800;
    text-transform: uppercase;
    line-height: 1;
    margin-top: 1px;
  }

  /* Color highlights for print cells */
  .print-cat-holiday { background: #ECFDF5 !important; }
  .print-cat-national { background: #FEF2F2 !important; }
  .print-cat-festival { background: #FFFBEB !important; }
  .print-cat-exam { background: #FEF3C7 !important; }
  .print-cat-event { background: #FCE4EC !important; }
  .print-cat-ptm { background: #F5F3FF !important; }
  .print-cat-academic { background: #E0F2FE !important; }
  .print-cat-other { background: #F1F5F9 !important; }

  /* Print Footer Legend */
  .print-official-footer {
    border-top: 1pt solid #cbd5e1;
    padding-top: 3px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 6.5pt;
    color: #334155;
  }

  .print-legend-group {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .print-legend-item {
    display: flex;
    align-items: center;
    gap: 3px;
  }

  .print-legend-box {
    width: 7px;
    height: 7px;
    border-radius: 1px;
    display: inline-block;
    border: 0.25pt solid #64748b;
  }

  .print-disclaimer-text {
    font-style: italic;
    color: #64748b;
  }
}
