/* HeadHunt chat-widget — kelluva pop-up oikeassa alakulmassa.
   Käyttää --hh-* CSS-muuttujia, ei riipu Bootstrapista eikä sivuston omasta
   CSS:stä. Selektorien etuliite #hh-chat-widget estää konfliktit.
*/

#hh-chat-widget {
  --hh-primary: #0C2340;
  --hh-accent: #2A5BD4;
  --hh-bg: #FFFFFF;
  --hh-border: #E5E7EB;
  --hh-text: #1F2937;
  --hh-muted: #6B7280;
  --hh-msg-visitor: #EFF6FF;
  --hh-msg-admin: #0C2340;
  --hh-success: #10B981;
  --hh-danger: #DC2626;
  position: fixed; z-index: 2147483646;
  bottom: 24px; right: 24px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--hh-text);
  line-height: 1.45;
}

/* Suljettu kupla (pelkkä nappi) */
#hh-chat-widget .hh-bubble {
  width: 60px; height: 60px;
  background: var(--hh-primary); color: #fff;
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, box-shadow .15s;
  border: none; padding: 0;
  position: relative;
}
#hh-chat-widget .hh-bubble:hover { transform: scale(1.05); box-shadow: 0 12px 32px rgba(0,0,0,.25); }
#hh-chat-widget .hh-bubble svg { width: 26px; height: 26px; fill: currentColor; }

/* Unread-badge bubblen päällä */
#hh-chat-widget .hh-unread-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 22px; height: 22px;
  background: var(--hh-danger);
  color: #fff;
  border-radius: 11px;
  font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  padding: 0 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  animation: hh-badge-pop .3s;
}
@keyframes hh-badge-pop {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Avoin paneeli */
#hh-chat-widget .hh-panel {
  position: absolute; bottom: 76px; right: 0;
  width: 360px; max-height: calc(100vh - 100px); min-height: 420px;
  background: var(--hh-bg);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.22);
  display: flex; flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--hh-border);
}

/* Mobiili: pienempi kupla sticky-footerin yläpuolelle, paneeli täysiruutu */
@media (max-width: 770px) {
  #hh-chat-widget {
    /* sticky-footer on noin 56-64px korkea — pidetään 80px että ei mene päälle */
    bottom: 80px;
    right: 14px;
  }
  #hh-chat-widget .hh-bubble {
    width: 48px; height: 48px;
  }
  #hh-chat-widget .hh-bubble svg { width: 22px; height: 22px; }
  #hh-chat-widget .hh-unread-badge {
    min-width: 18px; height: 18px; font-size: 10px;
    top: -3px; right: -3px;
  }
}

/* Mobiili: paneeli täysiruutu kun avoinna (pienemmillä näytöillä) */
@media (max-width: 600px) {
  #hh-chat-widget .hh-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    width: 100%; max-height: 100vh; min-height: 100vh;
    border-radius: 0;
  }
  #hh-chat-widget .hh-body { padding: 16px 14px; }
  #hh-chat-widget .hh-header { padding: 16px; }
  #hh-chat-widget .hh-header h3 { font-size: 16px; }
  #hh-chat-widget .hh-option { padding: 14px 14px; font-size: 15px; }
  #hh-chat-widget .hh-form input,
  #hh-chat-widget .hh-form textarea { font-size: 16px; /* estää zoom-iOSissa */ padding: 11px 13px; }
  #hh-chat-widget .hh-input-row input { font-size: 16px; padding: 11px 14px; }
  #hh-chat-widget .hh-rating .hh-star { font-size: 38px; padding: 6px; }
  #hh-chat-widget .hh-msg { max-width: 85%; font-size: 14px; }
}

/* Body scroll-lock kun chat avoinna */
body.hh-chat-locked { overflow: hidden !important; }
body.hh-chat-locked #hh-chat-widget .hh-panel { touch-action: pan-y; }

/* Header */
#hh-chat-widget .hh-header {
  background: var(--hh-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
#hh-chat-widget .hh-header h3 {
  margin: 0; font-size: 15px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
#hh-chat-widget .hh-header .hh-status-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--hh-success);
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(16,185,129,.6);
  animation: hh-pulse 2s infinite;
}
#hh-chat-widget .hh-header .hh-status-dot.offline { background: #9CA3AF; animation: none; box-shadow: none; }
@keyframes hh-pulse {
  0% { box-shadow: 0 0 0 0 rgba(16,185,129,.6); }
  70% { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}
#hh-chat-widget .hh-header .hh-header-actions { display: flex; gap: 4px; }
#hh-chat-widget .hh-header .hh-close,
#hh-chat-widget .hh-header .hh-minimize {
  background: none; border: none; color: #fff;
  font-size: 20px; line-height: 1; cursor: pointer;
  padding: 4px 10px; border-radius: 6px;
  font-family: inherit; font-weight: 700;
}
#hh-chat-widget .hh-header .hh-close { font-size: 22px; }
#hh-chat-widget .hh-header .hh-close:hover,
#hh-chat-widget .hh-header .hh-minimize:hover { background: rgba(255,255,255,.15); }

/* Body */
#hh-chat-widget .hh-body {
  flex: 1; overflow-y: auto;
  padding: 18px 16px; background: #FAFBFC;
}
#hh-chat-widget .hh-body h4 {
  margin: 0 0 16px; font-size: 15px; font-weight: 700; color: var(--hh-primary);
}
#hh-chat-widget .hh-body p { margin: 0 0 12px; font-size: 13.5px; color: var(--hh-text); }
#hh-chat-widget .hh-body small { font-size: 12px; color: var(--hh-muted); }

/* Valikkonappi (Layer-vaihtoehto) */
#hh-chat-widget .hh-option {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 13px 14px;
  margin-bottom: 8px;
  background: #fff;
  border: 1.5px solid var(--hh-border);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 600;
  color: var(--hh-text);
  text-align: left;
  transition: border-color .12s, background .12s, transform .08s;
}
#hh-chat-widget .hh-option:hover { border-color: var(--hh-accent); background: #F9FAFB; transform: translateX(2px); }
#hh-chat-widget .hh-option .hh-emoji { font-size: 20px; }

/* Takaisin-nuoli */
#hh-chat-widget .hh-back {
  background: none; border: none;
  color: var(--hh-muted); font-size: 12.5px; font-weight: 600;
  cursor: pointer; padding: 0; margin-bottom: 14px;
  display: inline-flex; align-items: center; gap: 4px;
}
#hh-chat-widget .hh-back:hover { color: var(--hh-accent); }

/* Vastaussisältö */
#hh-chat-widget .hh-answer { background: #fff; padding: 16px; border-radius: 10px; border: 1px solid var(--hh-border); }
#hh-chat-widget .hh-answer p { font-size: 13.5px; line-height: 1.55; }
#hh-chat-widget .hh-answer ul { margin: 8px 0 12px 18px; padding: 0; font-size: 13.5px; }
#hh-chat-widget .hh-answer li { margin-bottom: 4px; }
#hh-chat-widget .hh-answer a { color: var(--hh-accent); text-decoration: none; font-weight: 600; word-break: break-all; }
#hh-chat-widget .hh-answer a:hover { text-decoration: underline; }
#hh-chat-widget .hh-answer strong { color: var(--hh-primary); }

/* Lomake */
#hh-chat-widget .hh-form { display: flex; flex-direction: column; gap: 10px; }
#hh-chat-widget .hh-form label { font-size: 12px; font-weight: 700; color: var(--hh-muted); text-transform: uppercase; letter-spacing: .04em; }
#hh-chat-widget .hh-form input,
#hh-chat-widget .hh-form textarea {
  width: 100%; box-sizing: border-box;
  padding: 9px 12px; border: 1.5px solid var(--hh-border); border-radius: 8px;
  font-family: inherit; font-size: 14px;
  background: #fff; color: var(--hh-text);
}
#hh-chat-widget .hh-form input:focus,
#hh-chat-widget .hh-form textarea:focus { outline: none; border-color: var(--hh-accent); }
#hh-chat-widget .hh-form textarea { min-height: 90px; resize: vertical; }

/* Footer / primary button */
#hh-chat-widget .hh-footer {
  padding: 12px 16px; background: #fff;
  border-top: 1px solid var(--hh-border);
}
#hh-chat-widget .hh-btn {
  width: 100%; padding: 11px 16px;
  background: var(--hh-accent); color: #fff;
  border: none; border-radius: 8px;
  font-family: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer;
  transition: background .12s;
}
#hh-chat-widget .hh-btn:hover { background: #1E40AF; }
#hh-chat-widget .hh-btn:disabled { background: #9CA3AF; cursor: not-allowed; }
#hh-chat-widget .hh-btn-secondary { background: #F3F4F6; color: var(--hh-text); }
#hh-chat-widget .hh-btn-secondary:hover { background: #E5E7EB; }

/* Jono-näkymä */
#hh-chat-widget .hh-queue {
  text-align: center; padding: 20px 12px;
}
#hh-chat-widget .hh-queue .hh-queue-num {
  font-size: 48px; font-weight: 900; color: var(--hh-primary); margin: 8px 0;
}
#hh-chat-widget .hh-queue .hh-spinner {
  display: inline-block; width: 28px; height: 28px;
  border: 3px solid var(--hh-border); border-top-color: var(--hh-accent);
  border-radius: 50%; animation: hh-spin 1s linear infinite;
  margin: 8px;
}
@keyframes hh-spin { to { transform: rotate(360deg); } }

/* Chat-viestilista */
#hh-chat-widget .hh-messages {
  flex: 1; overflow-y: auto; padding: 14px 12px;
  display: flex; flex-direction: column; gap: 10px;
  background: #FAFBFC;
}
#hh-chat-widget .hh-msg { max-width: 80%; padding: 9px 13px; border-radius: 12px; font-size: 13.5px; word-wrap: break-word; white-space: pre-wrap; }
#hh-chat-widget .hh-msg-visitor { background: var(--hh-msg-visitor); color: var(--hh-primary); align-self: flex-end; border-bottom-right-radius: 4px; }
#hh-chat-widget .hh-msg-admin { background: var(--hh-msg-admin); color: #fff; align-self: flex-start; border-bottom-left-radius: 4px; }
#hh-chat-widget .hh-msg-system { background: transparent; color: var(--hh-muted); font-size: 11.5px; align-self: center; font-style: italic; }
#hh-chat-widget .hh-msg-time { font-size: 10px; color: var(--hh-muted); margin-top: 3px; text-align: right; }

/* Chat-kirjoituslaatikko */
#hh-chat-widget .hh-input-row {
  display: flex; gap: 8px; padding: 12px;
  background: #fff; border-top: 1px solid var(--hh-border);
}
#hh-chat-widget .hh-input-row input {
  flex: 1; padding: 9px 12px; border: 1.5px solid var(--hh-border); border-radius: 20px;
  font-family: inherit; font-size: 14px;
}
#hh-chat-widget .hh-input-row input:focus { outline: none; border-color: var(--hh-accent); }
#hh-chat-widget .hh-input-row button {
  width: 38px; height: 38px; background: var(--hh-accent); color: #fff;
  border: none; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
#hh-chat-widget .hh-input-row button:hover { background: #1E40AF; }
#hh-chat-widget .hh-input-row button svg { width: 16px; height: 16px; fill: currentColor; }

/* Virheviestit */
#hh-chat-widget .hh-error { background: #FEF2F2; border: 1px solid #FCA5A5; color: #991B1B; padding: 10px 12px; border-radius: 8px; font-size: 12.5px; margin-bottom: 10px; }
#hh-chat-widget .hh-success { background: #ECFDF5; border: 1px solid var(--hh-success); color: #065F46; padding: 12px; border-radius: 8px; font-size: 13.5px; }

/* Arvostelu */
#hh-chat-widget .hh-rating {
  background: #fff; padding: 18px 16px; border-radius: 10px; border: 1px solid var(--hh-border);
  text-align: center;
}
#hh-chat-widget .hh-rating h4 { margin: 0 0 6px; font-size: 16px; color: var(--hh-primary); }
#hh-chat-widget .hh-rating p { font-size: 12.5px; color: var(--hh-muted); margin: 0 0 14px; }
#hh-chat-widget .hh-stars { display: flex; justify-content: center; gap: 6px; margin-bottom: 14px; }
#hh-chat-widget .hh-star {
  background: none; border: none; cursor: pointer; padding: 4px;
  font-size: 32px; line-height: 1; color: #D1D5DB;
  transition: transform .1s, color .12s;
}
#hh-chat-widget .hh-star:hover { transform: scale(1.15); }
#hh-chat-widget .hh-star.filled { color: #F59E0B; }
#hh-chat-widget .hh-rating textarea {
  width: 100%; box-sizing: border-box;
  padding: 10px 12px; border: 1.5px solid var(--hh-border); border-radius: 8px;
  font-family: inherit; font-size: 13px; min-height: 70px; resize: vertical;
  margin-bottom: 12px;
}
#hh-chat-widget .hh-rating textarea:focus { outline: none; border-color: var(--hh-accent); }
#hh-chat-widget .hh-rating .hh-skip-btn {
  background: none; border: none; color: var(--hh-muted);
  font-size: 12.5px; cursor: pointer; margin-top: 8px;
  font-family: inherit;
}
#hh-chat-widget .hh-rating .hh-skip-btn:hover { color: var(--hh-accent); text-decoration: underline; }

/* Vahvistus-modal sulkemiselle */
#hh-chat-widget .hh-confirm-overlay {
  position: absolute; inset: 0; background: rgba(12,35,64,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 10; padding: 20px;
}
#hh-chat-widget .hh-confirm {
  background: #fff; border-radius: 12px; padding: 20px;
  max-width: 320px; box-shadow: 0 16px 40px rgba(0,0,0,.3);
}
#hh-chat-widget .hh-confirm h4 { margin: 0 0 10px; color: var(--hh-primary); font-size: 15px; }
#hh-chat-widget .hh-confirm p { font-size: 13px; color: var(--hh-text); margin: 0 0 16px; }
#hh-chat-widget .hh-confirm-buttons { display: flex; gap: 8px; }
#hh-chat-widget .hh-confirm-buttons button { flex: 1; padding: 9px; border-radius: 8px; border: none; font-family: inherit; font-weight: 700; cursor: pointer; }
#hh-chat-widget .hh-confirm-buttons .hh-danger-btn { background: var(--hh-danger); color: #fff; }
#hh-chat-widget .hh-confirm-buttons .hh-cancel-btn { background: #F3F4F6; color: var(--hh-text); }

/* Otsikko sub-sivulla (esim. "Hakemuksen tila") */
#hh-chat-widget .hh-subheader {
  background: var(--hh-primary); color: #fff;
  padding: 10px 16px; display: flex; align-items: center; gap: 10px;
}
#hh-chat-widget .hh-subheader .hh-back-icon {
  background: rgba(255,255,255,.12); border: none; color: #fff;
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  font-size: 16px;
}
#hh-chat-widget .hh-subheader .hh-back-icon:hover { background: rgba(255,255,255,.25); }
#hh-chat-widget .hh-subheader span { font-size: 14px; font-weight: 700; }

/* Estä widgetin sisäisestä koodista vuotamasta tyyliä sivustolle */
#hh-chat-widget * { box-sizing: border-box; }
#hh-chat-widget button { font-family: inherit; }
