/* Real Estate Chat Assistant — widget styles
   Boja se postavlja iz admina (--rea-accent, --rea-envelope-color,
   --rea-launcher-bg, --rea-teaser-bg, --rea-teaser-text, inline preko JS-a).
   Sve ostalo je neutralna, "profesionalna agencija" paleta koja ne
   sudara se s bojom brenda stranice na koju se widget ugrađuje. */

#rea-widget-root {
    --rea-accent: #0a2e5c;
    --rea-accent-ink: #ffffff;
    --rea-launcher-bg: #0a2e5c;
    --rea-envelope-color: #ffffff;
    --rea-teaser-bg: #ffffff;
    --rea-teaser-text: #1c2230;
    --rea-bg: #ffffff;
    --rea-surface: #f4f5f7;
    --rea-text: #1c2230;
    --rea-text-muted: #6b7280;
    --rea-border: #e4e6eb;
    --rea-error: #b3261e;
    --rea-radius-bubble: 14px;
    --rea-radius-pill: 999px;
    --rea-shadow: 0 12px 32px rgba(16, 24, 40, 0.16);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    position: fixed;
    z-index: 999999;
    right: 20px;
    bottom: 20px;
}

#rea-widget-root * { box-sizing: border-box; }

/* -------- Pokretač (zatvoreni widget) -------- */
.rea-launcher {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--rea-launcher-bg);
    color: var(--rea-envelope-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--rea-shadow);
    transition: transform 0.15s ease;
    padding: 0;
}
.rea-launcher:hover { transform: scale(1.06); }
.rea-launcher:focus-visible { outline: 3px solid var(--rea-accent); outline-offset: 3px; }
.rea-launcher svg { width: 30px; height: 30px; }
.rea-envelope-svg { display: block; }

/* -------- Teaser balončić -------- */
.rea-teaser {
    position: absolute;
    right: 76px;
    bottom: 10px;
    background: var(--rea-teaser-bg);
    color: var(--rea-teaser-text);
    border-radius: 14px;
    padding: 10px 34px 10px 14px;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.4;
    box-shadow: var(--rea-shadow);
    max-width: 240px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    transform: translateX(8px);
}
.rea-teaser.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}
.rea-teaser::after {
    /* Mali "rep" koji pokazuje prema launcheru */
    content: "";
    position: absolute;
    right: -6px;
    bottom: 18px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 7px solid var(--rea-teaser-bg);
    filter: drop-shadow(2px 0 1px rgba(16, 24, 40, 0.04));
}
.rea-teaser-text { display: inline-block; }
.rea-teaser-close {
    position: absolute;
    top: 4px;
    right: 6px;
    background: transparent;
    border: none;
    color: var(--rea-teaser-text);
    opacity: 0.55;
    font-size: 18px;
    line-height: 1;
    padding: 2px 4px;
    cursor: pointer;
    border-radius: 4px;
}
.rea-teaser-close:hover { opacity: 1; }

/* -------- Panel -------- */
.rea-panel {
    position: absolute;
    right: 0;
    bottom: 76px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: var(--rea-bg);
    border-radius: 18px;
    box-shadow: var(--rea-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: rea-panel-in 0.18s ease;
}
@keyframes rea-panel-in {
    from { opacity: 0; transform: scale(0.94) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    .rea-panel { animation: none; }
}

/* -------- Header (back + history | avatar + ime | jezik + zatvori) -------- */
.rea-header {
    background: var(--rea-accent);
    color: var(--rea-accent-ink);
    padding: 12px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}
.rea-header-actions-left {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}
.rea-header-btn {
    background: transparent;
    border: none;
    color: var(--rea-accent-ink);
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    opacity: 0.85;
    transition: background 0.15s ease, opacity 0.15s ease;
}
.rea-header-btn:hover { background: rgba(255,255,255,0.15); opacity: 1; }
.rea-header-btn:disabled { opacity: 0.35; cursor: default; }

.rea-header-identity {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    flex: 1;
    justify-content: center;
}
.rea-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1.5px solid rgba(255,255,255,0.5);
}
.rea-header-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rea-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.rea-lang-select {
    background: rgba(255,255,255,0.15);
    color: var(--rea-accent-ink);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    font-size: 12px;
    padding: 4px 6px;
    max-width: 80px;
}
.rea-lang-select option { color: #111; }
.rea-close-btn {
    background: transparent;
    border: none;
    color: var(--rea-accent-ink);
    cursor: pointer;
    padding: 4px;
    display: flex;
    opacity: 0.85;
}
.rea-close-btn:hover { opacity: 1; }

/* -------- History panel -------- */
.rea-history-panel {
    background: var(--rea-bg);
    border-bottom: 1px solid var(--rea-border);
    max-height: 55%;
    overflow-y: auto;
    flex-shrink: 0;
}
.rea-history-header {
    padding: 12px 16px 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--rea-text-muted);
    font-weight: 600;
}
.rea-history-empty {
    padding: 8px 16px 16px;
    font-size: 13px;
    color: var(--rea-text-muted);
    font-style: italic;
}
.rea-history-list {
    list-style: none;
    margin: 0;
    padding: 0 8px 8px;
}
.rea-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    transition: background 0.12s ease;
}
.rea-history-item:hover { background: var(--rea-surface); }
.rea-history-item-info {
    min-width: 0;
    flex: 1;
}
.rea-history-item-preview {
    font-size: 13px;
    color: var(--rea-text);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rea-history-item-date {
    font-size: 11px;
    color: var(--rea-text-muted);
    margin-top: 2px;
}
.rea-history-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.rea-history-continue,
.rea-history-delete {
    background: transparent;
    border: 1px solid var(--rea-border);
    color: var(--rea-text);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.rea-history-continue:hover {
    background: var(--rea-accent);
    border-color: var(--rea-accent);
    color: var(--rea-accent-ink);
}
.rea-history-delete {
    color: var(--rea-error);
    border-color: rgba(179, 38, 30, 0.25);
}
.rea-history-delete:hover {
    background: var(--rea-error);
    border-color: var(--rea-error);
    color: #fff;
}

/* -------- Poruke -------- */
.rea-messages {
    flex: 1;
    min-height: 60px;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--rea-surface);
}

.rea-bubble {
    max-width: 84%;
    padding: 10px 13px;
    border-radius: var(--rea-radius-bubble);
    font-size: 13.5px;
    line-height: 1.45;
    animation: rea-msg-in 0.15s ease;
}
@keyframes rea-msg-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.rea-bubble-bot {
    align-self: flex-start;
    background: var(--rea-bg);
    color: var(--rea-text);
    border: 1px solid var(--rea-border);
    border-bottom-left-radius: 4px;
}
.rea-bubble-user {
    align-self: flex-end;
    background: var(--rea-accent);
    color: var(--rea-accent-ink);
    border-bottom-right-radius: 4px;
}

/* -------- Opcije / gumbi -------- */
.rea-options {
    align-self: flex-start;
    max-width: 92%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 2px;
}
.rea-option-btn {
    background: var(--rea-bg);
    border: 1.5px solid var(--rea-accent);
    color: var(--rea-accent);
    border-radius: var(--rea-radius-pill);
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}
.rea-option-btn:hover { background: var(--rea-accent); color: var(--rea-accent-ink); }
.rea-option-btn:disabled { opacity: 0.5; cursor: default; }

/* -------- Input area -------- */
/* Forma s više polja je viša od panela: input-area se skrola (max 68% panela),
   a gumb Pošalji ostaje zalijepljen na dnu pa se nikad ne odreže. */
.rea-input-area {
    border-top: 1px solid var(--rea-border);
    padding: 10px 12px;
    background: var(--rea-bg);
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 0;
}
.rea-input-area .rea-send-row {
    position: sticky;
    bottom: 0;
    background: var(--rea-bg);
    padding: 8px 0 10px;
    z-index: 1;
    box-shadow: 0 -8px 8px -6px rgba(0,0,0,0.12);
}
.rea-field-row { margin-bottom: 6px; }
.rea-field-row label {
    display: block;
    font-size: 11.5px;
    color: var(--rea-text-muted);
    margin-bottom: 2px;
}
.rea-field-row input[type="text"],
.rea-field-row input[type="tel"],
.rea-field-row input[type="email"],
.rea-field-row input[type="number"],
.rea-field-row textarea {
    width: 100%;
    padding: 6px 10px;
    border: 1.5px solid var(--rea-border);
    border-radius: 10px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--rea-text);
}
.rea-field-row input:focus,
.rea-field-row textarea:focus {
    outline: none;
    border-color: var(--rea-accent);
}
.rea-field-row textarea { resize: vertical; min-height: 44px; height: 44px; }
.rea-field-error { color: var(--rea-error); font-size: 11.5px; margin-top: 3px; }

.rea-gdpr-row {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    font-size: 12px;
    color: var(--rea-text-muted);
    margin: 4px 0 6px;
}
.rea-gdpr-row input { margin-top: 2px; }
.rea-gdpr-row a { color: var(--rea-accent); }

.rea-send-row { display: flex; justify-content: flex-end; }
.rea-send-btn {
    background: var(--rea-accent);
    color: var(--rea-accent-ink);
    border: none;
    border-radius: var(--rea-radius-pill);
    padding: 9px 20px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
}
.rea-send-btn:disabled { opacity: 0.55; cursor: default; }

.rea-restart-row { padding: 6px 16px 14px; }
.rea-restart-btn {
    background: transparent;
    border: 1px solid var(--rea-border);
    color: var(--rea-text-muted);
    border-radius: var(--rea-radius-pill);
    padding: 6px 14px;
    font-size: 12px;
    cursor: pointer;
}

/* -------- Typing indicator -------- */
.rea-typing { display: flex; gap: 4px; padding: 4px 2px; }
.rea-typing span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--rea-text-muted);
    animation: rea-typing-bounce 1.1s infinite ease-in-out;
}
.rea-typing span:nth-child(2) { animation-delay: 0.15s; }
.rea-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes rea-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* -------- Responsive -------- */
@media (max-width: 420px) {
    #rea-widget-root { right: 12px; bottom: 12px; }
    .rea-panel { width: calc(100vw - 24px); height: calc(100vh - 100px); }
    .rea-teaser { max-width: 200px; font-size: 12.5px; }
}

/* ============================================================ */
/* PREGLED PONUDE PO ŽUPANIJAMA                                  */
/* ============================================================ */

/* Poseban razmak za "Pregledaj ponudu" na početnom ekranu. */
.rea-options-browse {
    margin-top: 6px;
}

/* Istaknuti (primary) gumb — za glavne akcije (Pregledaj ponudu,
   Pošalji upit, Otvori ponudu). Koristi boju agencije. */
.rea-option-btn-primary {
    background: var(--rea-accent);
    color: var(--rea-accent-ink);
    border-color: var(--rea-accent);
}
.rea-option-btn-primary:hover {
    background: var(--rea-accent);
    color: var(--rea-accent-ink);
    opacity: 0.9;
}

/* Neutralni (ghost) gumb — za sekundarne akcije (Natrag, Odaberi drugu). */
.rea-option-btn-ghost {
    background: transparent;
    border-color: var(--rea-border);
    color: var(--rea-text-muted);
}
.rea-option-btn-ghost:hover {
    background: var(--rea-surface);
    color: var(--rea-text);
}

/* Kontejner za gumbe županija. */
.rea-counties {
    max-width: 100%;
}
.rea-county-btn {
    font-size: 12.5px;
    padding: 7px 12px;
}

/* Mala napomena ispod županija (npr. "Klikom na županiju otvara se..."). */
.rea-browse-hint {
    font-size: 11.5px;
    color: var(--rea-text-muted);
    margin: 6px 2px 8px;
    font-style: italic;
}

/* Donje akcije u browse-u (Pošalji upit + Natrag) — vizualno odvojeno. */
.rea-browse-actions {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--rea-border);
    width: 100%;
}

/* Napomena "Agent se javlja u roku 24 radna sata" u kontakt formi. */
.rea-response-note {
    font-size: 12px;
    color: var(--rea-text-muted);
    background: var(--rea-surface);
    border-left: 3px solid var(--rea-accent);
    padding: 5px 10px;
    margin: 4px 0 4px;
    border-radius: 0 6px 6px 0;
    line-height: 1.4;
}

/* ============================================================ */
/* Podnaslov "virtualni asistent", info traka, reset gumb       */
/* ============================================================ */
.rea-header-text { min-width: 0; text-align: left; }
.rea-header-subtitle {
    font-size: 11px;
    line-height: 1.2;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rea-lang-select { max-width: 68px; font-size: 11.5px; }

.rea-info-strip {
    background: var(--rea-bg);
    border-bottom: 1px solid var(--rea-border);
    padding: 7px 14px;
    font-size: 11.5px;
    line-height: 1.4;
    color: var(--rea-text-muted);
    flex-shrink: 0;
}
.rea-info-name { font-weight: 600; color: var(--rea-text); font-size: 12px; }
.rea-info-line { display: flex; flex-wrap: wrap; gap: 2px 10px; }
.rea-info-item { color: var(--rea-text-muted); text-decoration: none; }
a.rea-info-item:hover { color: var(--rea-accent); text-decoration: underline; }
