/* ============================================================================
   Calendar Designer — UI styles
   ============================================================================ */

html, body { height: 100% !important; }
body {
  background: #f6f7f9;
  display: flex !important;
  flex-direction: column !important;
  margin: 0 !important;
}

/* Navbar takes its natural height; app-shell fills the rest */
body > nav { flex: 0 0 auto; }
.app-shell {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow: hidden !important;     /* keep on app-shell to prevent column overflow,
                                       but body itself can still rubber-band */
  display: flex !important;
  flex-direction: column !important;
  width: 100%;
  max-width: 100%;
  padding: 0 !important;            /* override .app-shell .p-3 padding */
}
.app-shell {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  width: 100%;
  max-width: 100%;
  padding: 12px !important;        /* visual gutter lives here, outside the constrained row */
}
.app-shell > .row {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  margin: 0 !important;
  width: 100%;
  max-width: 100%;
  --bs-gutter-y: 0 !important;
  --bs-gutter-x: 12px !important;
}
.app-shell > .row > [class*="col-"] {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Both side and main cards fill their column */
aside > .card,
main  > .card {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  width: 100%;
}

/* Side panel's body scrolls internally when content overflows */
aside > .card > .card-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
}

/* Canvas card's body: at fit-zoom the canvas matches the available space so
   nothing scrolls; when the user zooms in past 100% of fit, internal scroll
   bars appear so they can pan around. */
main > .card > .card-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow: auto !important;
}

.card-header {
  height: 83px !important;
}

.card-header .nav-tabs .nav-link {
  font-size: 0.85rem;
  padding: 0.45rem 0.6rem;
}

/* Color picker row */
.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0;
  font-size: 0.875rem;
}
.color-row span { color: #495057; }
.pickr .pcr-button {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid #ced4da;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Canvas wrapper */
#canvasWrap {
  background: linear-gradient(45deg, #d6d6d6 25%, transparent 25%),
              linear-gradient(-45deg, #d6d6d6 25%, transparent 25%),
              linear-gradient(45deg, transparent 75%, #d6d6d6 75%),
              linear-gradient(-45deg, transparent 75%, #d6d6d6 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, 10px 0;
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
#previewCanvas {
  display: block;
  background: transparent;
}

/* Nameday editor */
.nameday-row {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.35rem 0;
  border-bottom: 1px solid #eee;
}
.nameday-row .nd-date { font-weight: 600; color: #495057; font-size: 0.85rem; }
.nameday-row .nd-input { font-size: 0.85rem; }

/* Holiday editor */
.holiday-row {
  padding: 0.5rem 0.25rem;
  border-bottom: 1px solid #eee;
}
.holiday-row .hd-top {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}
.holiday-row .hd-bot {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem;
}
.holiday-row .hd-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  white-space: nowrap;
}
.holiday-row .hd-tag.fixed  { background: #cfe2ff; color: #0a58ca; }
.holiday-row .hd-tag.easter { background: #fff3cd; color: #997404; }
.holiday-row .hd-day {
  width: 60px;
  text-align: center;
  flex: 0 0 60px;
}
.holiday-row .hd-month {
  flex: 1 1 auto;     /* take remaining row space for the month name */
  min-width: 0;
}
.holiday-row .hd-offset {
  width: 75px;
  text-align: center;
}
.holiday-row .hd-name { font-size: 0.85rem; }
.holiday-row .hd-type { font-size: 0.85rem; max-width: 150px; }

/* Event list */
#eventList .list-group-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.5rem;
}
.evt-color-swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid #ced4da;
  cursor: pointer;
  flex: 0 0 auto;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.evt-color-swatch:hover {
  border-color: #495057;
}

/* Loader for fonts */
.font-loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Pickr's color popup defaults to z-index 10000, which sits OVER Bootstrap
   modals (z-index 1050-1055) and intercepts clicks on modal buttons. Lower it
   so modals work correctly even when a color popup is left open. */
.pcr-app {
  z-index: 1040 !important;
}

/* Font dropdown: render each option in its own font (works in Chrome/Firefox/Edge;
   Safari ignores per-option font styling and shows the system font instead). */
#ctlFont {
  font-size: 0.95rem;
}
#ctlFont option {
  font-size: 1rem;
  padding: 4px 6px;
}

/* Help icon next to form labels (Bootstrap tooltip trigger) */
.cd-help {
  cursor: help;
  opacity: 0.65;
  font-size: 0.85em;
}
.cd-help:hover { opacity: 1; }

/* Style accordion: tighten spacing so it doesn't dwarf the rest of the panel */
#styleAccordion {
  margin-bottom: 1rem;
}
#styleAccordion .accordion-button {
  padding: 0.6rem 0.9rem;
  font-weight: 600;
  font-size: 0.95rem;
}
#styleAccordion .accordion-body {
  padding: 0.75rem 0.9rem;
}

/* Custom font dropdown — works in every browser including Safari.
   The native #ctlFont <select> is hidden but kept for value/form semantics. */
.cd-font-dropdown {
  position: relative;
}
.cd-font-dropdown .cd-font-toggle {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  cursor: pointer;
}
.cd-font-dropdown .cd-font-current {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cd-font-dropdown .cd-font-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #ced4da;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 1030;          /* below modal backdrop (1050) and Pickr (1040) */
  margin-top: 2px;
  padding: 4px 0;
}
.cd-font-dropdown .cd-font-menu[hidden] { display: none; }
.cd-font-dropdown .cd-font-group {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  color: #D7263D;
  padding: 6px 12px 2px;
  letter-spacing: 0.04em;
}
.cd-font-dropdown .cd-font-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 6px 12px;
  font-size: 1.2rem;
  cursor: pointer;
  color: #212529;
}
.cd-font-dropdown .cd-font-item:hover {
  background: #f1f3f5;
}
.cd-font-dropdown .cd-font-item.active {
  background: #e7f1ff;
  color: #0a58ca;
  font-weight: 500;
}

/* Range picker */
#startWeekLabel, #endWeekLabel { font-size: 0.95rem; }
