/*
 * Basic styles for the vacation availability app. The layout is minimal
 * and responsive, adjusting automatically to narrow screens. Colours are
 * assigned dynamically by the script based on the palette defined in
 * server.js.
 */

body {
  margin: 0;
  /* Use a modern, system font stack for a clean look */
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  /* Slightly lighter background for a softer look */
  background: #fafafa;
  color: #333;
}

:root {
  --ui-radius: 18px;
}

#app {
  padding: 1rem;
  max-width: 900px;
  margin: 0 auto;
}

/* === NEU: kalender-layout + overlap-panel === */
#app {
  max-width: 1280px;
}

.calendar-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.overlap-panel {
  order: -1;
}

.overlap-panel-card {
  background: #fff;
  border: 1px solid #e3e3e3;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  padding: 1rem;
}

.overlap-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.overlap-panel-header-main {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.overlap-panel-card h3 {
  margin: 0;
  font-size: 1rem;
}

.overlap-viewmode-btn,
.overlap-sort-btn,
.overlap-toggle-btn {
  padding: 0.35rem 0.65rem;
  font-size: 0.82rem;
  line-height: 1.2;
  background: #f3f4f6;
  color: #333;
  border: 1px solid #d9d9d9;
  border-radius: 999px;
  cursor: pointer;
  max-width: 100%;
  white-space: normal;
}

.overlap-viewmode-btn:hover,
.overlap-sort-btn:hover,
.overlap-toggle-btn:hover {
  background: #e9ecef;
}

.overlap-viewmode-btn {
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.overlap-viewmode-btn svg {
  width: 1.1rem;
  height: 1.1rem;
}

.overlap-viewmode-btn.is-active {
  background: #e5efe8;
  border-color: #b7d1bf;
  color: #1f6f43;
}

.overlap-toggle-btn {
  display: inline-flex;
  margin-top: 0.65rem;
}

.overlap-section + .overlap-section {
  margin-top: 1rem;
}

.overlap-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #666;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.overlap-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.overlap-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
}

.overlap-list-item-month-divider {
  border-top: 1px solid #e8e8e8;
  padding-top: 0.55rem;
  margin-top: 0.55rem;
}

.overlap-list-main {
  min-width: 0;
}

.overlap-list-main-inline {
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
  align-items: center;
  column-gap: 1.2rem;
  width: 100%;
}

.overlap-range-link {
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.overlap-range-link:hover {
  background: none;
  color: #111;
  text-decoration: underline;
}

.overlap-range-link:focus-visible {
  outline: 2px solid rgba(239, 44, 135, 0.28);
  outline-offset: 3px;
}

.overlap-list-meta {
  margin-top: 0.15rem;
  font-size: 0.8rem;
  color: #666;
}

.overlap-list-meta-inline {
  margin-top: 0;
  min-width: 0;
}

.overlap-list-meta-side {
  margin-top: 0;
  text-align: left;
  justify-self: start;
  min-width: 0;
}

.overlap-list li strong {
  white-space: nowrap;
  font-size: 0.85rem;
  color: #666;
}

.overlap-list li + li {
  margin-top: 0.4rem;
}

.overlap-empty {
  color: #999;
}

@media (min-width: 960px) {
  .calendar-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
  }

  .calendar-container {
    grid-column: 1;
    grid-row: 1;
  }

  .overlap-panel {
    grid-column: 2;
    grid-row: 1;
    order: 0;
    position: sticky;
    top: 1rem;
  }
}

/* Forms and buttons */
.landing-hero {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding-top: 0.5rem;
  margin-bottom: 1rem;
}

.landing-hero-image {
  display: block;
  width: min(100%, 480px);
  height: auto;
  aspect-ratio: 1408 / 768;
  border-radius: 12px;
}

.form-section {
  background: #FFEEF9;
  border: none;
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: var(--ui-radius);
  color: #000;
}

.form-section h2 {
  margin-top: 0;
}

.form-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.5rem;
}

.form-row label {
  margin-bottom: 0.25rem;
}

.form-row input {
  background: #fff;
  padding: 0.5rem;
  border: none;
  border-radius: var(--ui-radius);
  font-size: 1rem;
  color: #000;
}

.form-feedback {
  min-height: 1.2rem;
  margin: -0.1rem 0 0.5rem;
  font-size: 0.9rem;
}

.form-feedback-error {
  color: #b91c1c;
}

.form-feedback-success {
  color: #166534;
}

button {
  padding: 0.55rem 1rem;
  font-size: 1rem;
  border: none;
  background: #ef2c87;
  color: #fff;
  border-radius: var(--ui-radius);
  cursor: pointer;
}

button:disabled {
  background: #f6a8ca;
  cursor: default;
}

/* Calendar layout */
.calendar-container {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Year header with navigation */
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: #fafafa;
  border-bottom: 1px solid #e0e0e0;
}

.calendar-header h2 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
}

.calendar-nav button {
  background: #fff;
  border: 1px solid #d9d9d9;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  color: #ef2c87;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  transition:
    color 0.15s ease,
    transform 0.15s ease,
    background-color 0.15s ease,
    border-color 0.15s ease;
}

.calendar-nav button:hover {
  background: #fdf1f7;
  border-color: #f4a5c8;
  color: #d61f72;
  transform: scale(1.04);
}

.calendar-nav button:focus-visible {
  outline: 2px solid rgba(239, 44, 135, 0.28);
  outline-offset: 3px;
  border-radius: 999px;
}

.calendar-nav button svg {
  width: 0.9rem;
  height: 0.9rem;
  display: block;
}

.calendar-nav button path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Container holding all months for a year */
.year-grid {
  padding: 1rem;
}

/* Each month card */
.month-container {
  background: #fff;
  border: 1px solid #e3e3e3;
  border-radius: 8px;
  margin-bottom: 1.25rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.month-header {
  padding: 0.5rem 0.75rem;
  background: #f5f5f5;
  border-bottom: 1px solid #e5e5e5;
  font-weight: 600;
}

.month-header-clickable {
  cursor: pointer;
  user-select: none;
}

.month-header-clickable:hover {
  background: #ececec;
}

.month-grid .day-name.day-name-clickable {
  cursor: pointer;
  user-select: none;
}

.month-grid .day-name.day-name-clickable:hover {
  background: #ececec;
}

/* Grid for a single month */
.month-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
}

.month-grid .day-name,
.month-grid .week-number {
  background: #f5f5f5;
  text-align: center;
  padding: 0.5rem 0;
  border-right: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
  font-weight: 600;
  font-size: 0.85rem;
}

.month-grid .week-number {
  cursor: pointer;
  user-select: none;
}

.month-grid .day-cell {
  min-height: 60px;
  border-right: 1px solid #f5f5f5;
  border-bottom: 1px solid #f5f5f5;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  background: #fff;
  transition: background-color 0.2s;
  isolation: isolate;
}

.month-grid .day-cell::before {
  content: "";
  position: absolute;
  inset: 0;
  background: transparent;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
}

.month-grid .day-cell::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 4px;
  border: 3px solid transparent;
  pointer-events: none;
  z-index: 3;
  box-sizing: border-box;
}

.month-grid .day-cell .availability-layer {
  position: absolute;
  inset: 0;
  display: grid;
  z-index: 1;
  pointer-events: none;
}

.month-grid .day-cell .availability-tile {
  display: block;
  min-width: 0;
  min-height: 0;
}

.month-grid .day-cell .availability-tile.tile-stretch {
  grid-column: 1 / -1;
}

.month-grid .day-cell .date-number,
.month-grid .day-cell .count-label {
  z-index: 4;
}

.month-grid .day-cell:hover {
  background: #fafafa;
}

.month-grid .day-cell.overlap-scroll-highlight {
  animation: none;
}

.month-grid .day-cell.overlap-scroll-highlight::before {
  animation: overlap-scroll-flash 1.45s ease-out;
}

.month-grid .day-cell.today .date-number {
  color: #111;
  font-weight: 700;
}

.month-grid .day-cell.today::after {
  border-color: #111;
}

.month-grid .day-cell.today .date-number {
  color: #111;
  font-weight: 700;
}

.month-grid .day-cell.past-day {
  background: #f3f3f3;
}

.month-grid .day-cell.past-day .date-number {
  color: #aaa;
}

.month-grid .day-cell.past-day .count-label {
  opacity: 0.65;
}

.month-grid .day-cell .date-number {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #666;
}

.month-grid .day-cell .count-label {
  position: absolute;
  bottom: 4px;
  right: 4px;
  font-size: 0.65rem;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  padding: 0 3px;
  border-radius: 3px;
}

/* Legend styling */
.legend {
  display: flex;
  flex-wrap: wrap;
  margin-top: 1rem;
  gap: 0.5rem;
}

.legend-item {
  display: flex;
  align-items: center;
  font-size: 0.9rem;
  padding: 0.35rem 0.65rem;
  background: #fff;
  border: 1px solid #e3e3e3;
  border-radius: 999px;
}

.legend-item-selectable {
  cursor: pointer;
}

.legend-item-selectable:focus-visible {
  outline: 2px solid #198754;
  outline-offset: 2px;
}

.legend-item .colour-box {
  width: 14px;
  height: 14px;
  margin-right: 5px;
  border-radius: 999px;
  border: 1px solid #ccc;
}

.legend-item-add {
  gap: 0.4rem;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  background: #fff;
  border-radius: 999px;
  justify-content: center;
}

.legend-add-button,
.legend-add-submit,
.legend-add-cancel {
  border: none;
}

.legend-add-button {
  min-width: 100%;
  min-height: 100%;
  padding: 0;
  border-radius: 999px;
  background: #fff;
  color: #198754;
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.legend-add-button:hover {
  background: #fff;
  color: #157347;
}

.legend-add-form {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-add-input {
  width: 140px;
  max-width: 45vw;
  padding: 0.45rem 0.55rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
}

.legend-add-submit,
.legend-add-cancel {
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
}

.legend-add-cancel {
  background: #6c757d;
}

.hidden {
  display: none;
}

.edit-mode-hint {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: #666;
}

/* === NEU: overlap-ringe im vordergrund === */
.month-grid .day-cell.overlap::after {
  border-color: rgba(239, 68, 68, 0.55);
}

.month-grid .day-cell.almost-all::after {
  border-color: rgba(220, 38, 38, 0.95);
}

.month-grid .day-cell.all-available::after {
  border-color: rgba(34, 197, 94, 0.95);
}

@keyframes overlap-scroll-flash {
  0% {
    background: rgba(255, 255, 255, 0);
    opacity: 0;
  }

  20% {
    background: rgba(255, 255, 255, 0.42);
    opacity: 1;
  }

  100% {
    background: rgba(255, 255, 255, 0);
    opacity: 0;
  }
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .overlap-panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .overlap-panel-header-main {
    align-self: flex-start;
  }

  .overlap-sort-btn {
    align-self: flex-start;
  }

  .overlap-list li {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
  }

  .overlap-list-main-inline {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex: 1 1 auto;
    flex-wrap: wrap;
    min-width: 0;
  }

  .overlap-range-link,
  .overlap-list-meta-side,
  .overlap-list li strong {
    white-space: nowrap;
  }

  .month-grid .day-cell {
    min-height: 45px;
  }
  .month-grid {
    font-size: 0.8rem;
  }
  .calendar-header h2 {
    font-size: 1.2rem;
  }
}
