/* public/css/app.css — Option B "Warm display" applied. Caprasimo headlines on
   Cabin body, neo-brutalist chrome (hard 2px outline + offset shadow on cards
   and modal), cream paper background. Brand green topbar kept (the white logo
   needs it). Booking blocks live without drop shadows. */
:root {
  --primary: #2c6638;            /* brand green (deep moss) */
  --primary-dark: #1a4824;
  --primary-light: #3a8d3a;
  --accent: #9c4a2a;             /* warm rust secondary */
  --bg: #faf2e3;                 /* cream paper */
  --bg-soft: #fffbf0;            /* warm white surface */
  --text: #2b1d1a;               /* warm ink, not pure black */
  --text-muted: #705c54;
  --border: #2b1d1a;             /* the brutalist line is the ink itself */
  --line-soft: #ead9bd;          /* subtle dividers */
  --error: #b3261e;
  --success: #2c6638;
  --shadow: 4px 4px 0 #2b1d1a;
  --shadow-lg: 6px 6px 0 #2b1d1a;
  --radius: 12px;
  --space: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Cabin", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 15px;
}
h1, h2, h3 {
  font-family: "Caprasimo", Georgia, serif;
  font-weight: 400;
  letter-spacing: -0.005em;
  line-height: 1.1;
  color: var(--text);
}
h1 { font-size: clamp(28px, 4vw, 38px); }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
.menu { font-family: "Cabin", sans-serif; font-weight: 600; }
a { color: var(--accent); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }

/* Topbar: brand green so the white logo reads. Soft bottom border, no shadow. */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--primary);
  border-bottom: 2px solid var(--primary-dark);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: inline-flex; align-items: center; }
.brand:hover { text-decoration: none; }
.brand img { display: block; height: 32px; width: auto; }
.menu { display: flex; gap: 6px; align-items: center; }
.menu a {
  color: rgba(255,255,255,.82); font-family: "Cabin", sans-serif; font-weight: 600;
  font-size: 14px; padding: 7px 14px; border-radius: 999px; text-decoration: none;
}
.menu a:hover { color: #fff; background: rgba(255,255,255,.10); text-decoration: none; }
.menu a.active { color: #fff; background: rgba(255,255,255,.18); }
.topbar .btn { background: #fff; color: var(--primary-dark); border-color: var(--primary-dark);
  box-shadow: 2px 2px 0 var(--primary-dark); }
.topbar .btn:hover { background: var(--bg); }
.hamburger { display: none; background: none; border: 0; font-size: 24px; cursor: pointer; color: #fff; }

main { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }

/* Cards: brutalist outline + offset shadow */
.card {
  background: var(--bg-soft); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 28px; box-shadow: var(--shadow);
}
.field { margin-bottom: 16px; }
.field label {
  display: block; margin-bottom: 6px; font-family: "Cabin", sans-serif;
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 14px; font-size: 15px;
  border: 2px solid var(--border); border-radius: 10px; background: #fff;
  font-family: "Cabin", inherit; color: var(--text);
}
.field textarea { resize: vertical; min-height: calc(1.5em * 4 + 20px); line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 0; box-shadow: 3px 3px 0 var(--border);
}
.field .checkbox-row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.field .checkbox-row input[type="checkbox"] { width: auto; margin: 0; transform: scale(1.15); accent-color: var(--primary); }

.btn {
  display: inline-block; padding: 11px 22px;
  border: 2px solid var(--border); border-radius: 999px;
  background: var(--primary); color: #fff; cursor: pointer; font-size: 15px;
  font-family: "Cabin", sans-serif; font-weight: 700;
  min-height: 44px; box-shadow: 3px 3px 0 var(--border);
  transition: transform .08s ease-out, box-shadow .08s ease-out;
}
.btn:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--border); }
.btn:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--border); }
.btn.secondary { background: var(--bg-soft); color: var(--text); }
.btn.danger { background: var(--error); }
.btn.small { padding: 6px 14px; font-size: 13px; min-height: 32px; box-shadow: 2px 2px 0 var(--border); }
.btn.small:hover { box-shadow: 3px 3px 0 var(--border); }

/* Toast: short, warm acknowledgements. One layer per surface. */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
  max-width: calc(100vw - 48px);
}
.toast {
  background: #1a1a1a;
  color: #f6f6f4;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(20, 30, 20, .22), 0 2px 6px rgba(0, 0, 0, .12);
  font-size: 14px;
  line-height: 1.35;
  pointer-events: auto;
  transform: translateY(8px) scale(.985);
  opacity: 0;
  transition: opacity .22s ease-out, transform .42s cubic-bezier(.18, .89, .32, 1.28);
  max-width: 360px;
  display: flex;
  align-items: center;
}
.toast.in { transform: translateY(0) scale(1); opacity: 1; }
.toast.out { opacity: 0; transform: translateY(-4px); transition: opacity .15s ease-in, transform .2s ease-in; }
.toast .toast-emoji { margin-right: 8px; font-size: 16px; }
@media (prefers-reduced-motion: reduce) {
  .toast, .toast.in, .toast.out { transition: opacity .1s linear !important; transform: none !important; }
}

/* Empty-state for /my — warm copy and a small wink. */
.empty-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  text-align: center;
  max-width: 480px;
  margin: 24px auto;
}
.empty-card h2 { margin: 0 0 10px; font-size: 22px; }
.empty-card p { margin: 0 0 20px; color: var(--text-muted); }
.empty-card .empty-mark {
  font-size: 32px;
  margin-bottom: 12px;
  filter: saturate(.95);
}

.alert { padding: 12px 16px; border: 2px solid var(--border); border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.alert.error { background: #fde2e1; color: var(--error); }
.alert.success { background: #e1f3e3; color: var(--success); }
.alert.warn { background: #fff4d5; color: #6a4b00; }
.alert.info { background: #e0eef9; color: #14497a; }

.field-help { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.req { color: var(--error); margin-left: 2px; }

/* Tables */
table.data { width: 100%; border-collapse: collapse; background: var(--bg-soft); border: 2px solid var(--border); border-radius: 12px; overflow: hidden; }
table.data th, table.data td { padding: 12px 14px; text-align: left; border-bottom: 1px dashed var(--line-soft); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data th { background: var(--primary); color: #fff; font-family: "Cabin", sans-serif; font-weight: 700; font-size: 13px; letter-spacing: 0.02em; text-transform: uppercase; }

/* Kalender */
.cal-toolbar {
  display: flex; align-items: center; justify-content: center;
  gap: 18px; margin-bottom: 0; flex-wrap: wrap;
  padding: 16px;
}
/* Tvinga radbrytning i flex-raden (syns bara på mobil, se media-query). */
.cal-toolbar-break { display: none; }
.cal-date-label {
  font-family: "Caprasimo", Georgia, serif; font-weight: 400;
  font-size: clamp(20px, 2.6vw, 26px); text-align: center; cursor: pointer;
  padding: 4px 12px; border-radius: 12px; line-height: 1.1;
  letter-spacing: -0.005em; color: var(--text);
  /* Stor min-bredd så att även "Wednesday, December 31 2026" ryms utan att
     pilarna flyttas. tabular-nums + reserve gör resterande längdvariation oförändrad. */
  min-width: 460px;
  font-variant-numeric: tabular-nums;
}
.cal-date-label:hover { background: var(--bg-soft); }
.cal-arrow {
  background: var(--bg-soft); border: 2px solid var(--border); border-radius: 999px;
  padding: 0; cursor: pointer;
  width: 40px; height: 40px; min-height: 40px; min-width: 40px;
  font-family: "Caprasimo", serif; font-size: 18px; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 2px 2px 0 var(--border);
}
.cal-arrow:hover { transform: translate(-1px,-1px); box-shadow: 3px 3px 0 var(--border); }
.cal-arrow:active { transform: translate(1px,1px); box-shadow: 1px 1px 0 var(--border); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(43,29,26,.45); display: none; align-items: center; justify-content: center; z-index: 100; }
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-soft); border: 2px solid var(--border); border-radius: 16px;
  padding: 28px; max-width: 480px; width: 92vw; max-height: 90vh; overflow: auto; position: relative;
  box-shadow: var(--shadow-lg);
}
.modal h2 { margin-top: 0; margin-bottom: 4px; font-size: 26px; }
.modal-close {
  position: absolute; top: 8px; right: 10px;
  width: 36px; height: 36px;
  background: transparent; border: 0; cursor: pointer;
  font-size: 26px; line-height: 1;
  color: var(--text-muted); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg-soft); color: var(--text); }

/* Mobile */
@media (max-width: 640px) {
  .menu { display: none; position: fixed; top: 60px; left: 0; right: 0; background: var(--primary); flex-direction: column; gap: 0; padding: 8px 0; border-bottom: 1px solid var(--primary-dark); }
  .menu.open { display: flex; }
  .menu a { padding: 14px 24px; border-bottom: 1px solid var(--primary-dark); color: #fff; }
  .menu a.active { border-bottom: 1px solid var(--primary-dark); background: var(--primary-dark); }
  .hamburger { display: block; }
  main { padding: 16px; }

  /* Verktygsraden i två rader: pil + datum + pil på rad 1, knapparna på rad 2.
     Ta bort den breda min-bredden så datumet ryms mellan pilarna på en rad. */
  .cal-toolbar { gap: 10px; padding: 12px; }
  .cal-date-label {
    /* flex-basis 0 så att datumtextens bredd aldrig knuffar ut nästa-pilen på
       en ny rad (t.ex. när dagen blir tvåsiffrig). Etiketten växer/krymper i
       det utrymme som blir kvar mellan pilarna. */
    min-width: 0; flex: 1 1 0;
    font-size: clamp(15px, 4.6vw, 22px); padding: 4px 4px;
  }
  .cal-toolbar-break { display: block; flex-basis: 100%; height: 0; }
}

/* ---- Custom calendar grid ---- */
.cal-grid-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;          /* horisontell scroll på mobil + vertikal */
  max-height: calc(100vh - 180px);
  background: var(--bg);
}
.cal-grid {
  display: grid;
  /* grid-template-columns sätts dynamiskt i JS:
     60px för tidskolumnen + en kolumn per rum */
  grid-auto-rows: auto;
  position: relative;
  width: 100%;
  /* Inget min-width: max-content — gridet ska aldrig växa förbi viewporten.
     Kolumnerna krymper istället via minmax() och rum-namnen tillåts wrapa. */
}
.cal-corner {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 4;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-height: 40px;
}
.cal-room-head {
  position: sticky;
  top: 0;
  z-index: 3;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,.15);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  padding: 4px 6px;
  text-align: center;
  line-height: 1.15;
  /* Tillåt wrap så långa namn kan brytas på flera rader istället för att
     tvinga gridet bredare än viewporten. */
  word-break: break-word;
  hyphens: auto;
}
/* Kortformen (första ordet) visas bara på mobil vid scroll — se 600px-blocket. */
.cal-room-head .room-name-short { display: none; }
.cal-time-col {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 60px;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
}
.cal-time-lbl {
  position: absolute;
  left: 0;
  right: 0;
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 6px;
  display: flex;
  align-items: flex-start;
  line-height: 1;
  pointer-events: none;
}
.cal-time-lbl.major {
  color: var(--text);
  font-weight: 600;
}
.cal-room-col {
  position: relative;
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.cal-room-col:last-child { border-right: 0; }
.cal-cell {
  position: absolute;
  left: 0;
  right: 0;
  cursor: pointer;
  border-top: 1px dashed transparent;
}
/* Tjock linje på heltimme (00 min), tunn linje på halvtimme (30 min).
   Border-TOP gör att linjen ligger PÅ heltimme-raden — inte under kvarten innan. */
.cal-cell.hour { border-top: 2px solid var(--border); }  /* hel timme: svart */
.cal-cell.half { border-top: 1px solid #b8b8b3; }        /* halvtimme: ljusare */
.cal-cell.quarter { /* ingen synlig linje — håll det rent */ }
/* Inaktivera default hover-bg på enskild cell — hover-preview-overlayn
   ritar istället hela 60-min-blocket. */
.cal-hover-preview {
  position: absolute;
  left: 0;
  right: 0;
  background: var(--bg-soft);
  pointer-events: none;
  z-index: 0;
  padding: 2px 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.2;
}
.cal-drag-overlay {
  position: absolute;
  left: 2px;
  right: 2px;
  background: rgba(0, 106, 15, 0.18);
  border: 1px dashed var(--primary);
  border-radius: 4px;
  pointer-events: none;
  z-index: 2;
}

.cal-event {
  position: absolute;
  left: 3px;
  right: 3px;
  z-index: 1;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  color: #fff;
  padding: 3px 8px;
  font-family: "Cabin", sans-serif; font-weight: 500;
  font-size: 12px;
  line-height: 1.2;
  overflow: hidden;
  cursor: pointer;
  /* No drop shadow on calendar blocks — kept flat per design spec. */
}
.cal-event:hover { filter: brightness(.96); }
.cal-event.pending .cal-event-name { font-style: italic; }
.cal-event.pending {
  background: repeating-linear-gradient(45deg, var(--primary) 0 10px, var(--primary-dark) 10px 20px) !important;
  border-style: dashed; opacity: 1;
}
.cal-event-time { font-weight: 600; font-size: 16px; }
.cal-event-name { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event-company { font-size: 13px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event.prep-shadow {
  opacity: 0.32;
  pointer-events: none;
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.55) 0 6px, transparent 6px 12px);
  z-index: 0;
}

/* Återkommande husevent (Breakfast/Fika) — informativa, inte bokningar.
   Tonat grönt + heldragen kontur skiljer dem från pending (streckat).
   .cal-event sätter color:#fff för de solida bokningsfärgerna — här behöver
   texten mörkgrön ton för att synas mot den ljusa, tonade bakgrunden. */
.cal-event.recurring {
  background: rgba(0, 106, 15, 0.10);
  border: 1.5px solid rgba(0, 106, 15, 0.55);
  color: #006a0f;
  cursor: pointer;
  /* Riktiga bokningar (inkl. pending) renderas samtidigt i samma kolumn och
     måste vinna klick vid överlapp — annars blir användarens egen pending-
     bokning oåtkomlig under blocket. Samma lager som prep-shadow (z-index:0). */
  z-index: 0;
}
.cal-event.recurring .cal-event-time,
.cal-event.recurring .cal-event-name { color: inherit; }

/* Status-badge i view-popup */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; vertical-align: middle; }
.badge.pending { background: #fff4d5; color: #6a4b00; }
.badge.approved { background: #e1f3e3; color: var(--success); }
.badge.rejected { background: #fde2e1; color: var(--error); }

.cal-now-line {
  position: absolute;
  left: 60px;
  right: 0;
  height: 2px;
  background: #e53935;
  z-index: 5;
  pointer-events: none;
  box-shadow: 0 0 4px rgba(229,57,53,.4);
}

/* Flatpickr — markera "Idag" i den gröna primärfärgen. */
.flatpickr-day.today {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}
.flatpickr-day.today:hover {
  background: var(--primary-dark) !important;
  border-color: var(--primary-dark) !important;
}
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: var(--primary-dark) !important;
  border-color: var(--primary-dark) !important;
  color: #fff !important;
}

@media (max-width: 640px) {
  .cal-grid-wrap { max-height: calc(100vh - 200px); }
}

/* Mellanstor viewport (tablet/portrait): krymp font och padding men håll
   texten horisontell. Kolumnerna är fortfarande breda nog. */
@media (max-width: 900px) {
  .cal-grid { --cal-room-col-min: 80px; }
  .cal-room-head {
    font-size: 12px;
    padding: 0 4px;
    letter-spacing: 0;
  }
}

/* Smal viewport (mobil): rotera rum-namn vertikalt. Annars tvingar de
   längre namnen ("1-to-1 Video call Room") gridet bredare än viewporten.
   `min-width: 100%` overrider `max-content` så gridet aldrig växer utanför. */
@media (max-width: 600px) {
  .cal-grid {
    --cal-time-col-w: 36px;
    --cal-room-col-min: 32px;
    min-width: 100%;
  }
  .cal-room-head {
    height: 140px;
    font-size: 11px;
    padding: 8px 2px;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
    line-height: 1.1;
    letter-spacing: 0;
  }
  .cal-corner { height: 140px; }
  .cal-time-col { width: 36px; }
  .cal-time-lbl { font-size: 10px; padding: 0 2px; }
  .cal-now-line { left: 36px; }

  /* Scrollad kalender: visa bara första ordet av rumsnamnet och låt
     header-raden krympa, så mer av dagen syns. Full höjd/namn kommer
     tillbaka när man scrollar upp till toppen igen. */
  .cal-grid-wrap.is-scrolled .cal-room-head,
  .cal-grid-wrap.is-scrolled .cal-corner { height: auto; min-height: 40px; }
  .cal-grid-wrap.is-scrolled .cal-room-head .room-name-full { display: none; }
  .cal-grid-wrap.is-scrolled .cal-room-head .room-name-short { display: inline; }
}
