:root {
  /* 1) PRIMARY COLOR VAIHDETTU */
  --primary-color: #df9921;
  --primary-light: #f0b44b; /* Hieman vaaleampi sävy hoverille */
  
  /* Oletus (Vaalea teema) */
  --bg-color: #ffffff;
  --bg-glass: rgba(250, 251, 252, 0.95);
  --bg-header: rgba(255, 255, 255, 0.7); 
  --text-main: #333333;
  --text-light: #666666;
  --text-highlight: #777777;
  
  --input-bg: rgba(255, 255, 255, 0.9);
  --input-border: #e5e7eb;
  --input-focus-bg: rgba(255, 255, 255, 0.98);
  
  --bubble-bot-bg: #ffffff;
  --bubble-bot-shadow: 0 2px 8px rgba(0,0,0,0.06);
  --bubble-user-color: #000000;
  
  --gradient-start: rgba(255,255,255,0);
  --gradient-mid: rgba(255,255,255,0.6);
  --gradient-end: rgba(255,255,255,1);
  
  --menu-bg: rgba(255, 255, 255, 0.98);
  --menu-shadow: 0 4px 20px rgba(0,0,0,0.15);
  --menu-hover: #f3f4f6;

  /* Vakiot */
  --shadow-prompter: 0 4px 15px rgba(0,0,0,0.1);
  --shadow-strong: 0 12px 32px rgba(0,0,0,0.15);
  --radius-chat: 16px;
  --radius-bubble: 12px;
  --font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
}

/* --- TUMMA TEEMA --- */
[data-theme="dark"] {
  --bg-color: #1a1a1a;
  --bg-glass: rgba(20, 20, 25, 0.95);
  --bg-header: rgba(20, 20, 25, 0.8);
  --text-main: #f0f0f0;
  --text-light: #a0a0a0;
  --text-highlight: #cccccc;
  
  --input-bg: rgba(40, 40, 45, 0.9);
  --input-border: #444444;
  --input-focus-bg: rgba(50, 50, 55, 0.98);
  
  --bubble-bot-bg: #2d2d33;
  --bubble-bot-shadow: 0 2px 8px rgba(0,0,0,0.2);
  --bubble-user-color: #ffffff;
  
  --gradient-start: rgba(20,20,25,0);
  --gradient-mid: rgba(20,20,25,0.6);
  --gradient-end: rgba(20,20,25,1);
  
  --menu-bg: rgba(45, 45, 50, 0.98);
  --menu-shadow: 0 4px 20px rgba(0,0,0,0.4);
  --menu-hover: #3a3a40;
}

body {
  font-family: var(--font-family);
  margin: 0;
  background: transparent;
}

.tauoton-hidden-init {
  display: none !important;
  opacity: 0 !important;
}

/* --- CHAT LAUNCHER --- */
.chat-launcher {
  position: fixed; bottom: 24px; right: 24px; width: 60px; height: 60px;
  border-radius: 50%; background: var(--primary-color); border: none;
  box-shadow: 0 4px 12px rgba(147, 163, 174, 0.4); 
  cursor: pointer; z-index: 2147483647;
  display: flex; align-items: center; justify-content: center;
  transition: background-color 0.2s;
}
.chat-launcher:hover { background-color: var(--primary-light); }
.launcher-icon { width: 28px; height: 28px; stroke: white; stroke-width: 2; fill: none; transition: opacity 0.2s; position: absolute; }
.icon-chat { opacity: 1; }
.icon-close { opacity: 0; }
.chat-launcher.is-active .icon-chat { opacity: 0; }
.chat-launcher.is-active .icon-close { opacity: 1; }

/* --- NUOLINAPPI --- */
.tauoton-arrow-btn {
  position: fixed; bottom: 95px; right: 32px; width: 28px; height: 28px;
  background-color: var(--primary-color); border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
  display: none; justify-content: center; align-items: center;
  cursor: pointer; z-index: 2147483648; transition: background-color 0.2s;
}
.tauoton-arrow-btn:hover { background-color: var(--primary-light); }
.tauoton-arrow-svg { width: 14px; height: 14px; fill: #ffffff; transition: transform 0.4s; transform: rotate(-90deg); }
.tauoton-arrow-btn.is-open .tauoton-arrow-svg { transform: rotate(0deg); }

/* --- PROMPTER --- */
.tauoton-chat-overlay {
  position: fixed; bottom: 135px; right: 20px; width: auto; max-width: 300px;
  background-color: transparent; padding: 0; z-index: 2147483646;
  display: none; flex-direction: column; align-items: flex-end; gap: 10px;
  opacity: 0; transform: translateY(20px); transition: opacity 0.3s, transform 0.3s; pointer-events: none;
}
.tauoton-chat-overlay.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.tauoton-chat-overlay.hidden-force { display: none !important; }

.tauoton-welcome-bubble {
  background-color: white; border-radius: var(--radius-chat); border-bottom-right-radius: 4px;
  padding: 24px 20px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); margin-bottom: 4px;
  width: 100%; max-width: 280px; position: relative;
}
.tauoton-welcome-text { font-size: 14px; line-height: 1.6; color: #333; margin: 0; cursor: pointer; }
.tauoton-prompter-close {
  position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; opacity: 0.3; transition: opacity 0.2s; z-index: 10;
}
.tauoton-prompter-close:hover { opacity: 1; }
.tauoton-prompter-close svg { width: 12px; height: 12px; fill: #000; }

/* NAPIT */
.tauoton-btn, .tauoton-action-btn {
  display: inline-flex; justify-content: center; align-items: center; width: auto; min-width: 100px;
  padding: 10px 24px; text-align: center; border-radius: 100px; font-weight: 500; font-size: 13px;
  cursor: pointer; transition: background-color 0.2s, opacity 0.2s; text-decoration: none; box-sizing: border-box;
}
.tauoton-btn-primary { background-color: #ffffff; color: #333; border: none; box-shadow: 0 4px 12px rgba(0,0,0,0.15); gap: 8px; }
.tauoton-btn-primary:hover { opacity: 0.9; }
.tauoton-btn-secondary, .tauoton-btn-tertiary, .tauoton-action-btn { 
  background-color: var(--primary-color); color: white; border: none; box-shadow: 0 2px 5px rgba(0,0,0,0.15); 
}
.tauoton-btn-secondary:hover, .tauoton-btn-tertiary:hover, .tauoton-action-btn:hover { background-color: var(--primary-light); color: white; }
.tauoton-status-dot { width: 8px; height: 8px; background-color: #2ecc71; border-radius: 50%; position: relative; flex-shrink: 0; }
.tauoton-status-dot::after {
  content: ''; position: absolute; top: -2px; left: -2px; right: -2px; bottom: -2px;
  border-radius: 50%; border: 1px solid #2ecc71; opacity: 0; animation: tauotonPulse 1.5s infinite ease-out;
}
@keyframes tauotonPulse { 0% { transform: scale(0.8); opacity: 1; } 100% { transform: scale(2.2); opacity: 0; } }

/* --- CHAT IKKUNA --- */
.chat-container {
  position: fixed; bottom: 100px; right: 24px; width: 440px; height: 600px; max-height: 80vh;
  background: var(--bg-glass); 
  backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
  border-radius: var(--radius-chat); box-shadow: var(--shadow-strong);
  display: none; flex-direction: column; overflow: hidden; z-index: 2147483647;
  opacity: 0; pointer-events: none; transform: translateY(20px) scale(0.98);
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.1); 
}
.chat-container.active { display: flex; opacity: 1; pointer-events: all; transform: translateY(0) scale(1); }

/* Header & Menu */
.chat-header { 
  background: var(--bg-header); backdrop-filter: blur(5px);
  border-bottom: 1px solid rgba(255,255,255,0.1); flex-shrink: 0; position: relative;
  z-index: 30; /* TÄMÄ KORJAA MENUN NÄKYVYYDEN */
  box-shadow: 0 2px 14px rgba(0,0,0,0.1);
}
.header-top { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; }
.brand-logo { height: 24px; width: auto; display: block; }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* HEADER STATUS DOT */
.header-status-dot {
  width: 8px; height: 8px; background-color: #2ecc71;
  border-radius: 50%; position: relative; flex-shrink: 0;
  margin-right: 12px;
}
.header-status-dot::after {
  content: ''; position: absolute; top: -2px; left: -2px; right: -2px; bottom: -2px;
  border-radius: 50%; border: 1px solid #2ecc71; opacity: 0; animation: tauotonPulse 1.5s infinite ease-out;
}

.icon-btn { 
  background: transparent; border: none; cursor: pointer; padding: 12px; border-radius: 50%; 
  display: flex; opacity: 0.5; transition: all 0.2s; color: var(--text-main);
}
.icon-btn:hover { background: rgba(150,150,150,0.1); opacity: 1; }

/* Dropdown Menu */
.chat-menu-dropdown {
  position: absolute; top: 50px; right: 20px; width: 220px; /* LEVEÄMPI */
  background: var(--menu-bg); border-radius: 12px;
  box-shadow: var(--menu-shadow); backdrop-filter: blur(10px);
  display: none; flex-direction: column; padding: 6px; z-index: 100;
  border: 1px solid rgba(255,255,255,0.1);
}
.chat-menu-dropdown.active { display: flex; animation: fadeInMenu 0.2s ease-out; }
@keyframes fadeInMenu { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

.menu-item {
  background: transparent; border: none; width: 100%; padding: 10px 12px;
  text-align: left; font-family: inherit; font-size: 14px; color: var(--text-main);
  border-radius: 8px; cursor: pointer; display: flex; align-items: center; gap: 10px;
  transition: background 0.2s; font-weight: 400; /* NORMAALI FONT WEIGHT */
}
.menu-item:hover { background: var(--menu-hover); }
.menu-item svg { width: 18px; height: 18px; opacity: 0.7; }

/* Switch Toggle (Dark Mode) */
.switch-container { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.switch { position: relative; display: inline-block; width: 34px; height: 20px; pointer-events: none; /* Klikkaus menee labelille */ }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc; transition: .4s; border-radius: 34px;
}
.slider:before {
  position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px;
  background-color: white; transition: .4s; border-radius: 50%;
}
input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(14px); }


/* TABS - PÄIVITETTY KÄYTTÄMÄÄN PRIMARY COLORIA */
.tabs-nav { display: flex; padding: 0 16px; gap: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs-nav::-webkit-scrollbar { display: none; } 
.tab-link {
  background: transparent; border: none; padding: 10px 4px; font-family: inherit; font-size: 13px;
  font-weight: 500; color: var(--text-light); cursor: pointer; position: relative; transition: color 0.2s; white-space: nowrap;
}
.tab-link:hover { color: var(--primary-color); } /* HOVER VÄRI */
.tab-link.active { color: var(--primary-color); font-weight: 600; } /* AKTIIVINEN TEKSTI */
.tab-link.active::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 2px; 
  background: var(--primary-color); /* AKTIIVINEN VIIVA */
  border-radius: 2px;
}

.view-container { flex: 1; position: relative; overflow: hidden; background: transparent; }
.view-section {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; flex-direction: column;
  opacity: 0; pointer-events: none; transform: translateX(15px); transition: opacity 0.3s, transform 0.3s; background: transparent;
}
.view-section.active { opacity: 1; pointer-events: auto; transform: translateX(0); z-index: 1; }

/* CHAT MESSAGES */
.chat-messages { 
    flex: 1; overflow-y: auto; padding: 20px 20px 100px 20px; 
    display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; 
    overscroll-behavior-y: contain; /* ESTÄÄ TAUSTAN SCROLLAUKSEN */
}

/* BUBBLES */
.bubble {
  padding: 14px 18px; border-radius: var(--radius-bubble); max-width: 85%; font-size: 14px; line-height: 1.6;
  position: relative; word-wrap: break-word; 
}
/* Bottiviestien kappalevälit selkeämmiksi (vain markdown/HTML sisällölle) */
.bubble.bot p {
  margin: 0 0 14px 0;
}

.bubble.bot p:last-child {
  margin-bottom: 0;
}

/* Otsikot jos niitä tulee markdownista */
.bubble.bot h1,
.bubble.bot h2,
.bubble.bot h3 {
  margin: 0 0 10px 0;
}

/* Listat jos niitä tulee */
.bubble.bot ul,
.bubble.bot ol {
  margin: 10px 0 14px 18px;
  padding: 0;
}

.bubble.bot li {
  margin: 6px 0;
}

.bubble.bot { 
  align-self: flex-start; background: var(--bubble-bot-bg); color: var(--text-main); 
  border-bottom-left-radius: 4px; box-shadow: var(--bubble-bot-shadow); border: 1px solid rgba(255,255,255,0.05);
}
.bubble.user { 
  align-self: flex-end; background: transparent; color: var(--bubble-user-color); 
  border-bottom-right-radius: 4px; padding-right: 0; text-align: right; box-shadow: none;
}
.bubble p { margin: 0 0 6px 0; }
.bubble p:last-child { margin-bottom: 0; }
.bubble a { color: inherit; text-decoration: underline; }

.bubble.typing {
  padding: 14px 18px; background: var(--bubble-bot-bg); border-bottom-left-radius: 4px; align-self: flex-start;
  display: flex; align-items: center; gap: 5px; width: fit-content; min-height: 20px;
  box-shadow: var(--bubble-bot-shadow);
}
.typing-dot { width: 5px; height: 5px; background: #bbb; border-radius: 50%; animation: typingBounce 1.4s infinite ease-in-out both; }
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typingBounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* ACTION BUTTON */
.action-container { align-self: flex-start; margin-top: -6px; margin-bottom: 6px; width: 100%; max-width: 85%; }

/* INPUT */
.chat-input-area { 
    position: absolute; bottom: 0; left: 0; width: 100%; padding: 16px 20px; 
    background: linear-gradient(to bottom, var(--gradient-start) 0%, var(--gradient-mid) 25%, var(--gradient-end) 100%);
    flex-shrink: 0; z-index: 10; box-sizing: border-box;
}

.input-pill {
  position: relative; display: flex; align-items: center; 
  background: var(--input-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-radius: 100px; transition: all 0.2s; padding: 6px; min-height: 48px; 
  border: 1px solid var(--input-border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.11), 0 2px 6px rgba(0,0,0,0.05);
}
.input-pill:focus-within { 
    background: var(--input-focus-bg); border-color: #acacac;
    box-shadow: 0 10px 30px rgba(0,0,0,0.12); 
}

.chat-input {
  flex: 1; border: none; background: transparent; padding: 0 16px; height: 100%; font-family: inherit; font-size: 16px; outline: none; color: var(--text-main);
}
.chat-input::placeholder { color: #aaa; font-size: 14px; }

/* SEND BUTTON */
.send-btn-round {
  width: 38px; height: 38px; border-radius: 50%; border: none; background: transparent; color: var(--primary-color);
  display: flex; align-items: center; justify-content: center; cursor: pointer; 
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s; flex-shrink: 0; margin-right: 2px;
}
.send-btn-round:hover { color: var(--primary-light); transform: rotate(30deg); }
.send-btn-round svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

/* GLOBAL FOOTER */
.global-footer { 
  padding: 12px 20px; background: var(--bg-color); border-top: 1px solid rgba(0,0,0,0.05); 
  text-align: center; font-size: 11px; color: #999; line-height: 1.5; flex-shrink: 0; 
  display: flex; flex-direction: column; z-index: 20;
}
.global-footer a { color: inherit; text-decoration: none; border-bottom: 1px dotted #ccc; transition: color 0.2s; }
.global-footer a:hover { color: var(--text-main); border-bottom-style: solid; }

.provider-link { display: inline-block; color: #999; text-decoration: none !important; border-bottom: none !important; transition: opacity 0.2s; }
.provider-link:hover { opacity: 0.8; }
.brand-highlight { font-weight: 600; color: var(--text-highlight); }

/* CONTACT & BOOKING */
.contact-view { 
    padding: 24px 20px; align-items: flex-start; background: var(--bg-color); overflow-y: auto; 
    overscroll-behavior-y: contain; /* ESTÄÄ TAUSTAN SCROLLAUKSEN */
}
.contact-card { width: 100%; background: rgba(255,255,255,0.05); border: 1px solid rgba(0,0,0,0.05); border-radius: 12px; padding: 20px; box-sizing: border-box; margin-bottom: 16px; }
.contact-header { font-size: 13px; font-weight: 600; color: var(--text-light); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }

.booking-view { background: var(--bg-color); overflow: hidden; display: flex; flex-direction: column; }
.booking-frame { width: 100%; height: 100%; border: none; flex: 1; }

/* --- QUICK REPLIES (PIKAVASTAUKSET) - FINAL STYLE --- */
.quick-replies-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px; /* 16px väli tervehdykseen */
  margin-bottom: 20px;
  align-items: flex-start;
  width: 100%;
  max-width: 85%;
  
  /* Animaatioita varten */
  opacity: 1;
  max-height: 500px;
  transform: translateY(0);
  transition: all 0.5s ease-out;
}

.quick-reply-btn {
  /* Tyyli: Ei taustaa, hieman tummempi reunus */
  background-color: transparent;
  color: var(--text-main);
  border: 1px solid rgba(0, 0, 0, 0.15); /* Hieman tummempi kuin aiemmin */
  box-shadow: none; 
  
  /* Koko ja fontti */
  padding: 8px 14px;
  border-radius: 20px;
  font-family: inherit;
  font-size: 12px; 
  line-height: 1.3;
  
  cursor: pointer;
  text-align: left;
  width: fit-content;
  max-width: 100%;
  
  /* Erottuvuus: Oletuksena hieman himmeä */
  opacity: 0.65; 
  transition: opacity 0.2s ease, border-color 0.2s ease;
}

.quick-reply-btn:hover {
  /* Hover: Reunus katoaa, teksti kirkastuu */
  background-color: transparent;
  border-color: transparent; /* Reunus katoaa */
  opacity: 1; /* Teksti kirkastuu täysin näkyviin */
  
  /* Varmistetaan ettei tapahdu muuta */
  transform: none;
  box-shadow: none;
}

/* POISTUMISANIMAATIO */
.quick-replies-container.qr-exit {
  opacity: 0;
  transform: translateY(-20px);
  max-height: 0;
  margin-top: 0;
  margin-bottom: 0;
  pointer-events: none;
}

/* MOBIILIOPTIMOINTI - KORJATTU */
@media (max-width: 480px) {
  /* CHAT IKKUNA MOBIILISSA: 4px margin ja täyttää ruudun */
  .chat-container { 
    position: fixed !important;
    top: 4px !important; 
    bottom: 4px !important; 
    left: 4px !important; 
    right: 4px !important; 
    width: auto !important; 
    height: auto !important; 
    max-height: none !important; 
    border-radius: 12px !important;
    transform: none !important;
  }

  /* PIILOTETAAN LAUNCHER KUN CHAT ON AUKI MOBIILISSA */
  .chat-launcher.is-active {
    display: none !important;
  }

  /* MUUT SÄÄDÖT - PROMPTER NOSTETTU */
  .tauoton-chat-overlay { 
      right: 20px; 
      bottom: 135px !important; /* NOSTETTU 100px -> 135px */
      align-items: flex-end; 
  }
  .tauoton-arrow-btn { right: 24px; bottom: 90px; }
  .chat-launcher { right: 24px; bottom: 24px; }
  .chat-input { font-size: 16px; }

  /* SCROLL LUKITUS */
  body.tauoton-no-scroll {
    position: fixed;
    width: 100%;
    overflow: hidden;
  }
}
