/* =========================================================
   Kalender – RT75 Göteborg-Gothia
   ========================================================= */

/* Layout */
.cal-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 32px;
  align-items: start;
}

/* ── Month navigation ──────────────────────────────────── */
.cal-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.cal-month-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary);
  min-width: 180px;
  text-align: center;
}

.cal-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 700;
  transition: background 0.15s, color 0.15s;
}

.cal-nav-btn:hover {
  background: var(--primary);
  color: #fff;
}

.cal-add-btn {
  margin-left: auto;
  min-height: 40px;
  padding: 8px 18px;
  font-size: 0.9rem;
}

/* ── Calendar grid ─────────────────────────────────────── */
.cal-grid-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.cal-header-cell {
  padding: 10px 6px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--primary);
  color: rgba(255,255,255,0.75);
  border-bottom: 2px solid var(--accent);
}

.cal-day {
  min-height: 90px;
  padding: 8px 6px 6px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  position: relative;
  vertical-align: top;
}

.cal-day:nth-child(7n) {
  border-right: none;
}

.cal-day-empty {
  background: var(--surface-2);
  opacity: 0.5;
}

.cal-day-num {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1;
  margin-bottom: 4px;
}

.cal-today .cal-day-num {
  background: var(--accent);
  color: var(--primary-dark);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}

.cal-has-events {
  background: #fdfbf3;
}

/* Event chips inside day cells */
.cal-day-events {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 2px;
}

.cal-ev-chip {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  line-height: 1.4;
  transition: opacity 0.12s;
}

.cal-ev-chip:hover {
  opacity: 0.8;
}

.cal-ev-meeting {
  background: var(--primary);
  color: var(--accent);
}

.cal-ev-general {
  background: #e0f2fe;
  color: #0369a1;
}

.cal-ev-time {
  opacity: 0.75;
  font-weight: 400;
  margin-right: 3px;
}

/* Dots (small screens / title hint) */
.cal-dots {
  display: none;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 2px;
}

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

.cal-dot-meeting { background: var(--primary); }
.cal-dot-general { background: #0ea5e9; }

/* Legend */
.cal-legend {
  display: flex;
  gap: 20px;
  align-items: center;
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--muted);
}

.cal-legend .cal-dot {
  width: 10px;
  height: 10px;
  margin-right: 5px;
  vertical-align: middle;
}

/* ── Sidebar – upcoming events ─────────────────────────── */
.cal-col-side {
  position: sticky;
  top: 100px;
}

.cal-side-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
  margin: 0 0 14px;
}

.cal-upcoming-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cal-upcoming-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  border-left: 4px solid var(--border);
  transition: box-shadow 0.15s;
}

.cal-upcoming-item:hover {
  box-shadow: 0 4px 16px rgba(16,31,91,0.1);
}

.cal-upcoming-meeting { border-left-color: var(--primary); }
.cal-upcoming-general { border-left-color: #0ea5e9; }

.cal-upcoming-date {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.3;
  padding-top: 2px;
}

.cal-upcoming-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.88rem;
  color: var(--text);
}

.cal-upcoming-time,
.cal-upcoming-loc {
  font-size: 0.8rem;
  color: var(--muted);
}

.cal-recur-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 2px 8px;
  margin-top: 2px;
  width: fit-content;
}

.cal-upcoming-edit {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: underline;
  white-space: nowrap;
  padding-top: 2px;
}

/* ── Add / Edit form ───────────────────────────────────── */
.cal-form-wrap {
  max-width: 620px;
}

.cal-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.cal-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.cal-required {
  color: #dc2626;
}

.cal-input {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}

.cal-input:focus {
  outline: none;
  border-color: var(--primary);
}

.cal-textarea {
  resize: vertical;
  min-height: 90px;
}

.cal-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
}

.cal-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.cal-checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

.cal-recurring-fields {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.cal-single-date-field {
  /* shown/hidden by JS */
}

.cal-form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.cal-alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 12px 16px;
  color: #991b1b;
  font-size: 0.9rem;
}

.cal-alert-error p {
  margin: 0 0 4px;
}

.cal-info-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cal-delete-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cal-btn-danger {
  background: #fef2f2;
  border: 1.5px solid #fca5a5;
  color: #991b1b;
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.cal-btn-danger:hover {
  background: #991b1b;
  color: #fff;
}

/* Read-only detail card */
.cal-detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

.cal-detail-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cal-detail-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.cal-detail-desc {
  margin: 4px 0 0;
  line-height: 1.7;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 900px) {
  .cal-layout {
    grid-template-columns: 1fr;
  }

  .cal-col-side {
    position: static;
    order: -1;
  }

  .cal-side-title {
    margin-top: 8px;
  }
}

@media (max-width: 640px) {
  .cal-day {
    min-height: 52px;
    padding: 5px 3px 4px;
  }

  .cal-day-events {
    display: none;
  }

  .cal-dots {
    display: flex;
  }

  .cal-add-btn {
    margin-left: 0;
    width: 100%;
    justify-content: center;
  }

  .cal-upcoming-item {
    grid-template-columns: 52px 1fr;
  }

  .cal-upcoming-edit {
    display: none;
  }
}
