/* ===========================================
 * FishPartner Calendar Stylesheet
 * =========================================== */

/* ===== Design tokens ===== */
.fp-calendar-wrapper {
  --fp-radius: 8px;
  --fp-avail-bg: #E3F9E5;
  --fp-avail-bg-hover: #D2F4D6;
  --fp-avail-text: #1B7A3D;
  --fp-avail-border: #8FD9A0;
  --fp-today-bg: #EAF2FF;
  --fp-today-text: #1D4ED8;
  --fp-border: #ECECEC;
  --fp-divider: #EDEDED;
  --fp-text-secondary: #6B7280;
}

/* ===== Typography and Layout ===== */
.fp-calendar-header {
  margin-bottom: 0.5em;
  text-align: left;
}

.fp-calendar-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5em;
  flex-wrap: wrap;
  gap: 0.5em;
}

.fp-calendar-title {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0;
}

.fp-calendar {
  font-family: system-ui, sans-serif;
}

/* ===== Calendar Table ===== */
.fp-calendar table {
  min-width: max-content;
  min-width: 700px;
  border-collapse: collapse;
  text-align: center;
  margin-bottom: 0;
}

.fp-calendar th,
.fp-calendar td {
  min-width: 60px;
  padding: 1em 0.8em;
  vertical-align: middle;
}

.fp-calendar th {
  background-color: #FAFAFA;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--fp-text-secondary);
  border-bottom: 1px solid var(--fp-border);
  box-shadow: inset -1px 0 0 var(--fp-divider);
  position: sticky;
  top: 0;
  z-index: 3;
}

.fp-calendar th:last-child {
  box-shadow: none;
}

.fp-weekday {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  opacity: 0.7;
  margin-bottom: 2px;
}

.fp-calendar td {
  font-size: 0.9rem;
  padding: 0.9em 0.7em;
  border: none;
  border-bottom: 1px solid #F3F4F6;
  box-shadow: inset -1px 0 0 var(--fp-divider);
  transition: background-color 0.2s ease;
}

.fp-calendar td:last-child {
  box-shadow: none;
}

.fp-calendar th.today {
  background-color: var(--fp-today-bg);
  color: var(--fp-today-text);
  font-weight: 600;
}

.fp-calendar td.empty.today {
  background-color: var(--fp-today-bg);
}

.fp-calendar td.available.today {
  background-color: var(--fp-today-bg);
}

.fp-calendar td.empty {
  background-color: #fff;
  color: #ccc;
}

.fp-calendar td:first-child,
.fp-calendar th:first-child {
  font-weight: 500;
  text-align: left;
  background-color: #fff;
  position: sticky;
  left: 0;
  z-index: 3;
}

/* The corner cell is both the sticky header row and the sticky first column,
   so it needs to sit above both of the sticky layers above. */
.fp-calendar th:first-child {
  z-index: 4;
  background-color: #FAFAFA;
}

/* ===== Navigation Buttons ===== */
.fp-calendar-nav {
  margin-bottom: 1em;
  text-align: right;
}

.fp-calendar-nav a.fp-nav-button {
  background-color: #f0f0f0;
  color: #333;
  padding: 8px 14px;
  border-radius: 50%;
  font-size: 1.2rem;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  transition: background 0.2s ease;
  width: 40px;
  height: 40px;
  text-decoration: none;
  margin: 0 0.25em;
}

.fp-calendar-nav a.fp-nav-button:hover {
  background-color: #ddd;
}

/* ===== Modal (Quick View) ===== */
.fp-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: none;
  z-index: 9999;
}

.fp-modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 1;
}

.fp-modal-dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  width: 90%;
  max-width: 700px;
}

.fp-modal-content {
  background: #fff;
  border-radius: 5px;
  padding: 2em;
  position: relative;
  z-index: 99999;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  
  max-height: 80vh;        /* limits height relative to viewport */
  overflow-y: auto;        /* allows vertical scroll if content overflows */
}

.fp-close {
  position: absolute;
  top: 0.5em;
  right: 0.7em;
  background: none;
  color: #5b5b5b;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 10px;
}

.fp-close:hover {
  color: #000;
  background-color: #fff;
  border-color: #fff;
}

/* ===== Cart Form ===== */
.fp-add-to-cart-form {
  margin-top: 1em;
  display: flex;
  gap: 0.5em;
  align-items: center;
}

.fp-add-to-cart-form input[type="number"] {
  width: 60px;
  padding: 0.3em;
}

/* ===== Loading Indicator ===== */
.fp-calendar-loading {
  opacity: 0.5;
  pointer-events: none;
  position: relative;
}

.fp-calendar-loading::after {
  content: "Sæki gögn…";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 0.5em 1em;
  border: 1px solid #ccc;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

/* ===== Trip Slot Styling ===== */
.fp-calendar td.available {
  position: relative;
  padding: 0;
}

.fp-slot {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--fp-avail-bg);
  color: var(--fp-avail-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.85rem;
  line-height: 1.2;
  z-index: 2;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

/* A trip's start and end always render as half-width, rounded inward toward
   the shared divider — the same whether or not it happens to be the very
   first/last trip of the season for this location. Only the days in
   between (middle) are full width. */
.fp-slot-middle {
  border-radius: 0;
}

.fp-slot-single {
  border-radius: var(--fp-radius);
}

.fp-slot-end,
.fp-slot-full-end {
  left: 0;
  right: auto;
  width: calc(50% - 1px);
  border-right: 1.5px solid #fff;
  border-radius: 0 var(--fp-radius) var(--fp-radius) 0;
}

.fp-slot-start,
.fp-slot-full-start {
  right: 0;
  left: auto;
  width: calc(50% - 1px);
  border-left: 1.5px solid #fff;
  border-radius: var(--fp-radius) 0 0 var(--fp-radius);
}

.fp-slot:hover,
.fp-slot.hovered {
  background-color: var(--fp-avail-bg-hover);
  box-shadow: inset 0 0 0 1px var(--fp-avail-border);
}

/* ===== Location Links ===== */
.fp-calendar td:first-child a {
  color: #2f7d32;
  text-decoration: none;
  font-weight: 600;
}

.fp-calendar td:first-child a:hover {
  text-decoration: underline;
  color: #1b5e20;
}

/* ===== Scroll and Fade Effects ===== */
.fp-calendar-scrollable::before,
.fp-calendar-scrollable::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 30px;
  pointer-events: none;
  z-index: 5;
}

.fp-calendar-scrollable {
  overflow: auto;
  max-height: 70vh;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  position: relative;
}

.fp-calendar-scrollable-wrapper {
  position: relative;
  max-width: 100%;
  margin-bottom: 1em;
  border: 1px solid var(--fp-border, #ECECEC);
  border-radius: 10px;
  overflow: hidden;
}

.fp-fade-left,
.fp-fade-right {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 30px;
  pointer-events: none;
  z-index: 10;
}

.fp-fade-right {
  right: 0;
  background: linear-gradient(to left, rgba(255,255,255,1), rgba(255,255,255,0));
}

/* ===== Mobile ===== */
@media (max-width: 480px) {
  .fp-modal-dialog {
    width: 100%;
    max-width: none;
    padding: 1em;
  }

  .fp-modal-content {
    max-height: 90vh;
    padding: 1em;
  }

  .fp-slot {
    font-size: 1rem;
  }

  .fp-calendar-nav {
    font-size: 0.95rem;
    text-align: center;
  }

  .fp-calendar-nav a {
    display: inline-block;
    padding: 0.5em 1em;
  }

  .fp-calendar th:first-child,
  .fp-calendar td:first-child {
    background-color: #fff;
    border-right: 1px solid #e0e0e0;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
    text-align: center;
  }

  .fp-calendar td.available:hover {
    box-shadow: none;
  }
}
