/*
 * Parfemi AI Chatbot — widget stilovi
 * Design: minimal, editorial, crno-bela paleta — koristi theme fontove preko font-family: inherit
 */

#parfemi-chatbot-root {
    /* Glavne boje (popunjava widget.php preko inline style) */
    --pc-header-bg:   #0a0a0a;
    --pc-header-text: #ffffff;
    --pc-body-bg:     #ffffff;
    --pc-body-text:   #0a0a0a;
    --pc-accent:      #0a0a0a;
    --pc-accent-text: #ffffff;

    /* Izvedene nijanse — računaju se iz glavnih boja */
    --pc-surface: color-mix(in srgb, var(--pc-body-text) 6%, var(--pc-body-bg));
    --pc-ink-soft: color-mix(in srgb, var(--pc-body-text) 55%, var(--pc-body-bg));
    --pc-border: color-mix(in srgb, var(--pc-body-text) 10%, transparent);
    --pc-border-strong: color-mix(in srgb, var(--pc-body-text) 18%, transparent);
    --pc-accent-soft: color-mix(in srgb, var(--pc-accent) 15%, transparent);
    --pc-accent-strong: color-mix(in srgb, var(--pc-accent) 85%, #000000);
    --pc-header-border: color-mix(in srgb, var(--pc-header-text) 15%, transparent);
    --pc-fab-pulse: var(--pc-accent); /* fallback ako nije inline postavljeno */

    --pc-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --pc-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --pc-shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.14);
    --pc-radius: 16px;
    --pc-radius-sm: 10px;

    font-family: inherit;
    color: var(--pc-body-text);
    line-height: 1.5;
}

/* ───── FAB (Floating Action Button) ───── */

#parfemi-chatbot-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 99998;
    display: flex !important;
    align-items: center;
    gap: 14px;
    padding: 6px 6px 6px 0;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    /* Tema ne sme da limitira FAB — neke teme imaju max-width na button */
    width: auto;
    max-width: none;
    min-width: 0;
    height: auto;
    overflow: visible;
    white-space: normal;
    text-transform: none;
    letter-spacing: normal;
}

#parfemi-chatbot-fab:hover {
    transform: translateY(-2px);
}

#parfemi-chatbot-fab .pc-fab-bubble {
    background: var(--pc-body-bg);
    color: var(--pc-body-text);
    padding: 10px 18px 10px 20px;
    border-radius: 999px;
    box-shadow: var(--pc-shadow-md);
    border: 1px solid var(--pc-border);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.01em;
    display: inline-flex !important;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
    white-space: nowrap;
    visibility: visible !important;
    opacity: 1;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.pc-fab-bubble small {
    font-size: 11px;
    color: var(--pc-ink-soft);
    font-weight: 400;
    margin-top: 2px;
}

.pc-fab-avatar {
    position: relative;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}

.pc-fab-avatar-inner {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    box-shadow: var(--pc-shadow-md);
    transition: box-shadow 0.3s ease;
    overflow: hidden;
    /* Background i boja aktiviraju se SAMO ako nema uploaded slike (SVG fallback) */
    background: transparent;
    color: var(--pc-accent-text);
}

/* SVG fallback (kad nije uploaded avatar) — treba mu boja da se vidi */
.pc-fab-avatar-inner:not(:has(img)) {
    background: var(--pc-accent);
}

.pc-fab-avatar-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.pc-fab-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--pc-fab-pulse);
    opacity: 0.35;
    animation: pc-pulse 2.4s ease-out infinite;
}

@keyframes pc-pulse {
    0%   { transform: scale(1);    opacity: 0.25; }
    70%  { transform: scale(1.5);  opacity: 0;    }
    100% { transform: scale(1.5);  opacity: 0;    }
}

/* Stanje kad je chat otvoren — sakrij bubble, pokaži X */
#parfemi-chatbot-root.pc-open .pc-fab-bubble {
    opacity: 0 !important;
    transform: translateX(20px) scale(0.9);
    pointer-events: none;
}
#parfemi-chatbot-root.pc-open .pc-fab-pulse {
    display: none;
}

/* ───── Window ───── */

#parfemi-chatbot-window {
    position: fixed;
    right: 24px;
    bottom: 96px;
    z-index: 99999;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 620px;
    max-height: calc(100vh - 120px);
    background: var(--pc-body-bg);
    border-radius: var(--pc-radius);
    box-shadow: var(--pc-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--pc-border);
}

#parfemi-chatbot-root.pc-open #parfemi-chatbot-window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ───── Header ───── */

.pc-head {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    background: var(--pc-header-bg);
    color: var(--pc-header-text);
    z-index: 2;
}

.pc-head-left {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.pc-head-avatar {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    background: transparent;
    border: none;
}

/* SVG fallback dobija bg + border */
.pc-head-avatar:not(:has(img)) {
    background: color-mix(in srgb, var(--pc-header-text) 12%, transparent);
    border: 1px solid var(--pc-header-border);
}

.pc-head-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pc-head-name {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.pc-head-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.8;
    margin-top: 2px;
}

.pc-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #5fd97a;
    box-shadow: 0 0 0 2px rgba(95, 217, 122, 0.3);
}

.pc-head-close {
    position: relative;
    z-index: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--pc-header-text) 10%, transparent);
    color: var(--pc-header-text);
    border: 1px solid var(--pc-header-border);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}
.pc-head-close:hover {
    background: color-mix(in srgb, var(--pc-header-text) 20%, transparent);
    transform: rotate(90deg);
}

/* ───── Messages ───── */

.pc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 20px 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    position: relative;
    z-index: 1;
    background: var(--pc-body-bg);
}

.pc-messages::-webkit-scrollbar {
    width: 6px;
}
.pc-messages::-webkit-scrollbar-track {
    background: transparent;
}
.pc-messages::-webkit-scrollbar-thumb {
    background: var(--pc-border-strong);
    border-radius: 3px;
}

.pc-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: pc-msg-enter 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pc-msg-enter {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pc-msg--bot  { align-self: flex-start; }
.pc-msg--user { align-self: flex-end; }

.pc-bubble {
    padding: 10px 14px;
    border-radius: var(--pc-radius-sm);
    font-size: 14.5px;
    line-height: 1.55;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.pc-msg--bot .pc-bubble {
    background: var(--pc-surface);
    color: var(--pc-body-text);
    border: 1px solid var(--pc-border);
    border-bottom-left-radius: 4px;
}

.pc-msg--user .pc-bubble {
    background: var(--pc-accent);
    color: var(--pc-accent-text);
    border-bottom-right-radius: 4px;
}

/* Predložena pitanja — chips ispod welcome message */
.pc-suggested {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    animation: pc-msg-enter 0.45s cubic-bezier(0.16, 1, 0.3, 1) 0.1s backwards;
}

.pc-suggested-chip {
    background: var(--pc-body-bg);
    border: 1px solid var(--pc-border-strong);
    color: var(--pc-body-text);
    padding: 7px 13px;
    border-radius: 999px;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    line-height: 1.3;
    white-space: nowrap;
}

.pc-suggested-chip:hover {
    background: var(--pc-accent);
    color: var(--pc-accent-text);
    border-color: var(--pc-accent);
    transform: translateY(-1px);
}

/* Typing indicator (3 dots + opciona labela) */
.pc-typing-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.pc-typing-label {
    font-size: 13px;
    color: var(--pc-ink-soft);
    font-style: italic;
}

.pc-typing {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}
.pc-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--pc-ink-soft);
    opacity: 0.5;
    animation: pc-typing 1.3s infinite ease-in-out;
}
.pc-typing span:nth-child(2) { animation-delay: 0.15s; }
.pc-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes pc-typing {
    0%, 60%, 100% { transform: translateY(0);   opacity: 0.4; }
    30%           { transform: translateY(-5px); opacity: 1;   }
}

/* Streaming cursor */
.pc-cursor {
    display: inline-block;
    width: 7px;
    height: 15px;
    background: var(--pc-accent);
    vertical-align: text-bottom;
    margin-left: 2px;
    animation: pc-blink 1s infinite;
}
@keyframes pc-blink {
    50% { opacity: 0; }
}

/* ───── Product cards ───── */

.pc-products {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    max-width: 100%;
}

.pc-product-card {
    display: flex;
    gap: 12px;
    padding: 10px;
    background: var(--pc-body-bg);
    border: 1px solid var(--pc-border);
    border-radius: var(--pc-radius-sm);
    box-shadow: var(--pc-shadow-sm);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    animation: pc-card-enter 0.4s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.pc-product-card:nth-child(1) { animation-delay: 0.1s; }
.pc-product-card:nth-child(2) { animation-delay: 0.2s; }
.pc-product-card:nth-child(3) { animation-delay: 0.3s; }

@keyframes pc-card-enter {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pc-product-card:hover {
    transform: translateY(-2px);
    border-color: var(--pc-accent);
    box-shadow: var(--pc-shadow-md);
}

.pc-product-image {
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    background: var(--pc-surface);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pc-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pc-product-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 6px;
}

.pc-product-brand {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--pc-ink-soft);
    font-weight: 600;
}

.pc-product-name {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--pc-body-text);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.pc-product-meta {
    font-size: 11px;
    color: var(--pc-ink-soft);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pc-product-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 2px;
}

.pc-product-price {
    font-weight: 700;
    font-size: 14px;
    color: var(--pc-body-text);
    letter-spacing: -0.01em;
}

.pc-product-cta {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: var(--pc-accent);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    transition: transform 0.2s ease;
}

.pc-product-card:hover .pc-product-cta {
    transform: translateX(2px);
}

/* ───── Archive links (brend / kategorija) ───── */

.pc-archives {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.pc-archive-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: var(--pc-accent);
    color: var(--pc-accent-text);
    border-radius: var(--pc-radius-sm);
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: pc-card-enter 0.4s cubic-bezier(0.16, 1, 0.3, 1) backwards;
    animation-delay: 0.1s;
}

.pc-archive-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--pc-shadow-md);
}

.pc-archive-body {
    flex: 1;
    min-width: 0;
}

.pc-archive-type {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.7;
    font-weight: 600;
}

.pc-archive-name {
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1.3;
    margin-top: 2px;
}

.pc-archive-count {
    font-size: 11.5px;
    opacity: 0.75;
    margin-top: 2px;
}

.pc-archive-cta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    transition: transform 0.2s ease;
}

.pc-archive-card:hover .pc-archive-cta {
    transform: translateX(3px);
}

/* Lokacijska kartica — vertikalni layout sa embed mapom */
.pc-archive-card--location {
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    background: var(--pc-body-bg);
    color: var(--pc-body-text);
    border: 1px solid var(--pc-border);
    overflow: hidden;
    cursor: default;
}

.pc-archive-card--location:hover {
    transform: none;
    box-shadow: var(--pc-shadow-sm);
}

.pc-location-label {
    padding: 12px 14px 2px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    color: var(--pc-ink-soft);
}

.pc-location-address {
    padding: 0 14px 10px;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--pc-body-text);
}

.pc-location-map {
    width: 100%;
    height: 180px;
    border: 0;
    display: block;
    background: var(--pc-surface);
}

.pc-location-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 14px;
    background: var(--pc-accent);
    color: var(--pc-accent-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    transition: filter 0.2s ease;
}

.pc-location-cta:hover {
    filter: brightness(1.08);
}

/* Akcijska kartica — suptilna "sale" estetika, dekorativna zvezda iza naslova */
.pc-archive-card--sale {
    position: relative;
    overflow: hidden;
}

.pc-archive-card--sale::before {
    content: "%";
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 72px;
    font-weight: 900;
    opacity: 0.08;
    line-height: 1;
    letter-spacing: -0.05em;
    pointer-events: none;
}

.pc-archive-card--sale .pc-archive-type {
    opacity: 0.9;
}

/* ───── Footer / input ───── */

.pc-footer {
    padding: 12px 16px 16px;
    background: var(--pc-body-bg);
    border-top: 1px solid var(--pc-border);
    position: relative;
    z-index: 2;
}

.pc-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--pc-body-bg);
    border: 1px solid var(--pc-border-strong);
    border-radius: 22px;
    padding: 6px 6px 6px 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.pc-input-wrap:focus-within {
    border-color: var(--pc-accent);
    box-shadow: 0 0 0 3px var(--pc-accent-soft);
}

.pc-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    color: var(--pc-body-text);
    max-height: 120px;
    padding: 6px 0;
}

.pc-input::placeholder {
    color: var(--pc-ink-soft);
}

.pc-send {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    background: var(--pc-accent);
    color: var(--pc-accent-text);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.pc-send:hover:not(:disabled) {
    background: var(--pc-accent-strong);
    transform: scale(1.05);
}

.pc-send:disabled {
    opacity: 0.5;
    cursor: default;
}

/* ───── Powered by footer ───── */

.pc-powered {
    text-align: center;
    font-size: 10.5px;
    color: var(--pc-ink-soft);
    padding: 6px 0 2px;
    letter-spacing: 0.02em;
}

.pc-powered a {
    color: inherit;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.15s ease;
}

.pc-powered a:hover {
    color: var(--pc-body-text);
}

/* ───── Error banner ───── */

.pc-error {
    padding: 10px 14px;
    background: #fafafa;
    color: #b3472c;
    border: 1px solid #f0d4c8;
    border-radius: var(--pc-radius-sm);
    font-size: 13px;
}

/* ───── Responsive ───── */

@media (max-width: 520px) {
    #parfemi-chatbot-window {
        right: 12px;
        left: 12px;
        bottom: 80px;
        width: auto;
        max-width: none;
        height: calc(100vh - 100px);
        height: calc(100dvh - 100px);
    }
    #parfemi-chatbot-fab {
        right: 14px;
        bottom: 14px;
        gap: 10px;
    }

    /* FAB bubble se vidi i na mobile-u, samo malo kompaktnije */
    #parfemi-chatbot-fab .pc-fab-bubble {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1;
        padding: 7px 12px 7px 14px;
        font-size: 12.5px;
        max-width: 160px;
        white-space: normal;
    }
    #parfemi-chatbot-fab .pc-fab-bubble small {
        font-size: 10px;
    }

    /* iOS ne zoom-uje input ako je font-size ≥ 16px */
    .pc-input {
        font-size: 16px;
    }

    /* Malo veći touch target za send dugme na mobilnom */
    .pc-send {
        width: 38px;
        height: 38px;
    }
}

/* Hide widget while loading to avoid FOUC */
#parfemi-chatbot-root:not(.pc-ready) {
    visibility: hidden;
}
