/* ============================================================
   Shared components: booking modal, chatbot widget, contact form
   Loaded on every page after the page's own CSS so it can override.
   ============================================================ */

:root {
  --green: #3E6B47;
  --green-deep: #2A4A31;
  --green-soft: #6B8F73;
  --green-tint: #E8EFE8;
  --paper: #FAF7F1;
  --paper-2: #F2EDE3;
  --ink: #15191A;
  --ink-2: #2D3330;
  --muted: #6B6F68;
  --rule: #1d211e22;
}

/* ============ MODAL BASE ============ */
.tas-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 22, 18, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  opacity: 0; visibility: hidden;
  transition: opacity .25s ease, visibility 0s linear .25s;
  display: grid; place-items: center;
  padding: 24px;
}
.tas-modal-overlay.open {
  opacity: 1; visibility: visible;
  transition: opacity .25s ease;
}
.tas-modal {
  background: var(--paper);
  width: 100%; max-width: 920px;
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  transform: scale(.95);
  opacity: 0;
  transition: transform .3s cubic-bezier(.2,.8,.2,1), opacity .25s ease;
  box-shadow: 0 24px 64px -12px rgba(0,0,0,.35);
  overflow: hidden;
  font-family: 'Inter', -apple-system, sans-serif;
}
.tas-modal-overlay.open .tas-modal {
  transform: scale(1);
  opacity: 1;
}
.tas-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  flex-shrink: 0;
}
.tas-modal-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 22px; font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0;
}
.tas-modal-title em { color: var(--green); font-style: italic; }
.tas-modal-close {
  width: 36px; height: 36px;
  border: 1px solid var(--rule);
  background: transparent;
  cursor: pointer;
  display: grid; place-items: center;
  color: var(--ink-2);
  transition: all .15s ease;
  font-size: 18px;
  line-height: 1;
}
.tas-modal-close:hover {
  border-color: var(--ink);
  background: var(--paper-2);
}
.tas-modal-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============ BOOKING MODAL ============ */
.booking-modal { max-width: 1080px; }
.booking-modal .tas-modal-body { padding: 0; display: flex; flex-direction: column; }

.booking-iframe-wrap {
  position: relative;
  flex: 1;
  min-height: 600px;
  background: var(--paper-2);
}
.booking-iframe {
  width: 100%; height: 100%;
  min-height: 600px;
  border: 0;
  display: block;
}
.booking-iframe-loading {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: var(--paper);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
}
.booking-spinner {
  width: 32px; height: 32px;
  border: 2px solid var(--rule);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Fallback variant — shown when iframe is blocked */
.booking-fallback {
  display: none;
  padding: 0;
}
.booking-fallback.active { display: block; }
.booking-iframe-wrap.fallback-mode { display: none; }

.booking-fb-hero {
  padding: 32px 40px 28px;
  background: var(--green);
  color: var(--paper);
}
.booking-fb-hero .eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--green-tint);
  display: block;
  margin-bottom: 8px;
}
.booking-fb-hero h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 400; font-size: 32px;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--paper);
}
.booking-fb-hero h2 em { color: var(--green-tint); font-style: italic; }

.booking-fb-services {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--rule);
  border-bottom: 1px solid var(--rule);
}
.booking-fb-card {
  padding: 28px 32px;
  background: var(--paper);
  display: flex;
  flex-direction: column;
}
.booking-fb-card .who {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--green);
  margin-bottom: 6px;
}
.booking-fb-card h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 500; font-size: 24px;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.booking-fb-card .price-line {
  display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}
.booking-fb-card .price {
  font-size: 18px; color: var(--ink);
  font-weight: 500;
}
.booking-fb-card .duration { color: var(--muted); }
.booking-fb-card p {
  color: var(--ink-2);
  font-size: 14px; line-height: 1.55;
  margin: 0 0 20px;
  flex: 1;
}
.booking-fb-card .btn-book {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--green);
  color: var(--paper);
  padding: 14px 22px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
  border: 0;
  cursor: pointer;
  align-self: flex-start;
  transition: background .15s ease, transform .15s ease;
}
.booking-fb-card .btn-book:hover {
  background: var(--green-deep);
  transform: translateY(-1px);
}
.booking-fb-card.armand .who { color: var(--green-soft); }
.booking-fb-card.armand .btn-book { background: var(--ink); }
.booking-fb-card.armand .btn-book:hover { background: var(--green-deep); }

.booking-fb-info {
  padding: 28px 40px;
  background: var(--paper-2);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
.booking-fb-info dt {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.booking-fb-info dd {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
}
.booking-fb-info dd strong { color: var(--ink); font-weight: 600; }

@media (max-width: 720px) {
  .tas-modal-overlay { padding: 0; }
  .tas-modal {
    max-width: 100%;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
  }
  .booking-fb-services { grid-template-columns: 1fr; }
  .booking-fb-info { grid-template-columns: 1fr 1fr; padding: 20px 24px; }
  .booking-fb-hero { padding: 24px; }
  .booking-fb-hero h2 { font-size: 24px; }
  .booking-fb-card { padding: 22px 24px; }
}

/* ============ CONTACT FORM MODAL ============ */
.contact-modal { max-width: 540px; }
.contact-modal .tas-modal-body { padding: 28px 32px 32px; }
.contact-form-intro {
  font-size: 14px; color: var(--ink-2);
  margin: 0 0 22px;
  line-height: 1.55;
}
.tas-form-row { margin-bottom: 16px; }
.tas-form-row label {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.tas-form-row input,
.tas-form-row textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  background: var(--paper);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  transition: border-color .15s ease;
}
.tas-form-row input:focus,
.tas-form-row textarea:focus {
  outline: none;
  border-color: var(--green);
}
.tas-form-row textarea {
  resize: vertical;
  min-height: 110px;
}
.tas-form-row.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.tas-form-submit {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--green);
  color: var(--paper);
  border: 0;
  padding: 14px 24px;
  font-family: inherit;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
  margin-top: 8px;
}
.tas-form-submit:hover { background: var(--green-deep); }
.tas-form-thanks {
  display: none;
  padding: 28px;
  text-align: center;
  background: var(--green-tint);
  color: var(--green-deep);
  font-family: 'Fraunces', Georgia, serif;
  font-size: 18px;
  margin-top: 12px;
}
.tas-form-thanks.show { display: block; }

/* ============ CHATBOT WIDGET ============ */
.tas-chat {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 150;
  font-family: 'Inter', -apple-system, sans-serif;
}
.tas-chat-btn {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--green);
  color: var(--paper);
  border: 0;
  cursor: pointer;
  box-shadow: 0 8px 24px -4px rgba(62, 107, 71, 0.45);
  display: grid; place-items: center;
  position: relative;
  transition: transform .2s ease, background .2s ease;
}
.tas-chat-btn:hover { background: var(--green-deep); transform: translateY(-2px); }
.tas-chat-btn svg { width: 26px; height: 26px; }
.tas-chat-btn .pulse {
  position: absolute;
  top: -2px; right: -2px;
  width: 14px; height: 14px;
  background: var(--clay, #B8754A);
  border-radius: 50%;
  border: 2px solid var(--paper);
  opacity: 0;
  transition: opacity .3s ease;
}
.tas-chat-btn .pulse.show {
  opacity: 1;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
/* Issue X — kun ÉN lukke-knapp i chatten: skjul den flytende
   launcher-knappen mens panelet er åpent, så bare X-en i panel-
   headeren (oppe til høyre) gjenstår. Launcheren kommer tilbake når
   chatten lukkes. .icon-close-svg-en er fjernet fra markup. */
.tas-chat.open .tas-chat-btn { display: none; }

.tas-chat-panel {
  position: absolute;
  bottom: 76px; right: 0;
  width: 360px;
  height: 540px;
  max-height: calc(100vh - 100px);
  background: var(--paper);
  border: 1px solid var(--rule);
  box-shadow: 0 20px 56px -12px rgba(0,0,0,.28);
  display: flex; flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(.97);
  transform-origin: bottom right;
  transition: opacity .2s ease, transform .25s cubic-bezier(.2,.8,.2,1), visibility 0s linear .25s;
  overflow: hidden;
}
.tas-chat.open .tas-chat-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition: opacity .2s ease, transform .25s cubic-bezier(.2,.8,.2,1);
}

.tas-chat-head {
  background: var(--green);
  color: var(--paper);
  padding: 16px 18px;
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}
.tas-chat-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--paper);
  color: var(--green);
  display: grid; place-items: center;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.tas-chat-head-text {
  flex: 1;
  min-width: 0;
}
.tas-chat-head-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 500;
  font-size: 16px;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.2;
}
.tas-chat-head-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  opacity: 0.8;
  margin-top: 4px;
  display: flex; align-items: center; gap: 6px;
}
.tas-chat-head-status::before {
  content: ""; width: 6px; height: 6px;
  background: #7AD68B;
  border-radius: 50%;
}
.tas-chat-close {
  background: transparent;
  border: 0;
  color: var(--paper);
  cursor: pointer;
  padding: 6px;
  opacity: 0.8;
  font-size: 18px;
  line-height: 1;
}
.tas-chat-close:hover { opacity: 1; }

/* V5: synlig disclaimer øverst i chat-vinduet. Diskret, men ikke til å overse. */
.tas-chat-disclaimer {
  background: #fff7d6;
  color: #4a3a00;
  border-bottom: 1px solid #e8d77a;
  padding: 10px 16px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.45;
  letter-spacing: 0.02em;
}

.tas-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}
.tas-msg {
  max-width: 85%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
.tas-msg-bot {
  align-self: flex-start;
  background: var(--paper-2);
  color: var(--ink);
  border-bottom-left-radius: 0;
}
.tas-msg-user {
  align-self: flex-end;
  background: var(--green);
  color: var(--paper);
  border-bottom-right-radius: 0;
}
.tas-msg a { color: var(--green); text-decoration: underline; }
.tas-msg-user a { color: var(--paper); }
.tas-msg p { margin: 0 0 8px; }
.tas-msg p:last-child { margin: 0; }

.tas-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px 14px;
  flex-shrink: 0;
}
.tas-quick-replies button {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  padding: 8px 12px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s ease;
  border-radius: 999px;
}
.tas-quick-replies button:hover {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-tint);
}

.tas-chat-input {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--rule);
  background: var(--paper);
  flex-shrink: 0;
}
.tas-chat-input input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--rule);
  background: var(--paper-2);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  border-radius: 999px;
}
.tas-chat-input input:focus {
  outline: none;
  border-color: var(--green);
  background: var(--paper);
}
.tas-chat-send {
  width: 40px; height: 40px;
  background: var(--green);
  color: var(--paper);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: background .15s ease;
}
.tas-chat-send:hover { background: var(--green-deep); }
.tas-chat-send:disabled { background: var(--muted); cursor: not-allowed; }
.tas-chat-send svg { width: 16px; height: 16px; }

.tas-typing {
  align-self: flex-start;
  background: var(--paper-2);
  padding: 14px 16px;
  display: flex; gap: 4px;
}
.tas-typing span {
  width: 6px; height: 6px;
  background: var(--muted);
  border-radius: 50%;
  animation: typing 1.2s infinite ease-in-out;
}
.tas-typing span:nth-child(2) { animation-delay: .15s; }
.tas-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 600px) {
  .tas-chat-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    bottom: 0; right: 0;
  }
  .tas-chat-btn { bottom: 16px; right: 16px; }
  .tas-chat { bottom: 16px; right: 16px; }
}

/* Bredere mobil-rule for posisjon + størrelse — fanger iPad portrait og store
   iPhones i landscape som er >600px men der knappen fortsatt skal være mindre
   påtrengende. */
@media (max-width: 900px) {
  .tas-chat { bottom: 16px; right: 16px; }
  .tas-chat-btn { width: 48px; height: 48px; }
  .tas-chat-btn svg { width: 22px; height: 22px; }
}

/* ============ FOOTER PARITY HELPERS (sticky CTA on mobile only) ============ */
.tas-mobile-cta {
  display: none;
}
@media (max-width: 600px) {
  .tas-mobile-cta {
    display: block;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--paper);
    border-top: 1px solid var(--rule);
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    z-index: 90;
    text-align: center;
  }
  .tas-mobile-cta a {
    display: block;
    background: var(--green);
    color: var(--paper);
    padding: 14px;
    font-weight: 600;
    text-decoration: none;
    font-size: 14px;
    letter-spacing: 0.01em;
  }
  /* leave room above mobile CTA so chat doesn't overlap — kun på sider der
     .tas-mobile-cta faktisk er rendret (i dag: bestilling.html). Tidligere
     regel var ubetinget og dyttet chat-knappen 76px opp på index.html også. */
  .tas-mobile-cta ~ .tas-chat { bottom: 76px; }
}
