.ai-faraon-widget {
    --af-bg: var(--dark, #101010);
    --af-panel: #191919;
    --af-gold: var(--heading, #d6b46a);
    --af-text: var(--text, #ffffff);
    --af-border: rgba(214, 180, 106, 0.25);

    position: fixed;
    right: 24px;
    bottom: 80px;
    z-index: 999999;
    font-family: inherit;
    color: var(--af-text);
}

.ai-faraon-widget *,
.ai-faraon-widget *::before,
.ai-faraon-widget *::after {
    box-sizing: border-box;
}

.ai-faraon-panel[hidden] {
    display: none !important;
}

.ai-faraon-panel {
    position: absolute;
    right: 0;
    bottom: 94px;
    display: flex;
    flex-direction: column;
    width: 370px;
    height: min(560px, calc(100dvh - 140px));
    min-height: 330px;
    overflow: hidden;
    background-color: var(--af-bg);
    background-image:
        linear-gradient(rgba(16, 16, 16, 0.6), rgba(16, 16, 16, 0.6)),
        var(--af-panel-bg, url('ozadje-faraon-ai.png'));
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    border: 1px solid var(--af-border);
    border-radius: 20px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
    animation: ai-faraon-appear 180ms ease-out;
}

.ai-faraon-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(135deg, #202020, #111111);
    border-bottom: 1px solid var(--af-border);
}

.ai-faraon-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.ai-faraon-header-avatar {
    display: block;
    width: 46px;
    height: 46px;
    overflow: hidden;
    border: 1px solid var(--af-gold);
    border-radius: 50%;
    flex-shrink: 0;
}

.ai-faraon-header-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.4) translateY(-9%);
    transform-origin: center;
}

.ai-faraon-header h2 {
    margin: 0;
    color: var(--af-gold);
    font-size: 19px;
    line-height: 1.3;
}

.ai-faraon-header p {
    margin: 3px 0 0;
    color: #b9b9b9;
    font-size: 12px;
}

.ai-faraon-close {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    color: var(--af-text);
    background: #292929;
    border: 1px solid #383838;
    border-radius: 50%;
    font-size: 25px;
    cursor: pointer;
}

.ai-faraon-close:hover {
    color: var(--af-gold);
    border-color: var(--af-gold);
}

.ai-faraon-messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 12px;
    padding: 18px 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.ai-faraon-message {
    max-width: 90%;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.ai-faraon-answer {
    align-self: flex-start;
    color: #ededed;
    background: #252525;
    border: 1px solid #333333;
    border-top-left-radius: 4px;
}

.ai-faraon-sources {
    margin: 10px 0 0;
    padding-top: 8px;
    border-top: 1px solid #333333;
    color: #9a9a9a;
    font-size: 11px;
    line-height: 1.5;
    white-space: normal;
}

.ai-faraon-sources a {
    color: var(--af-gold);
    text-decoration: none;
}

.ai-faraon-sources a:hover {
    text-decoration: underline;
}

.ai-faraon-user {
    align-self: flex-end;
    color: #17130b;
    background: var(--af-gold);
    border-top-right-radius: 4px;
}

.ai-faraon-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: #151515;
    border-top: 1px solid var(--af-border);
}

.ai-faraon-input {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 11px 13px;
    color: #ffffff;
    background: #242424;
    border: 1px solid #3b3b3b;
    border-radius: 12px;
    outline: none;
    font: inherit;
    font-size: 14px;
}

.ai-faraon-input::placeholder {
    color: #999999;
}

.ai-faraon-input:focus {
    border-color: var(--af-gold);
    box-shadow: 0 0 0 2px rgba(214, 180, 106, 0.12);
}

.ai-faraon-send {
    min-height: 44px;
    padding: 0 14px;
    color: #17130b;
    background: var(--af-gold);
    border: 0;
    border-radius: 12px;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.ai-faraon-send:hover {
    filter: brightness(1.08);
}

.ai-faraon-send:disabled {
    opacity: 0.6;
    cursor: wait;
}

.ai-faraon-footnote {
    margin: 0;
    padding: 0 12px 10px;
    color: #888888;
    background: #151515;
    text-align: center;
    font-size: 10px;
}

.ai-faraon-launcher {
    display: grid;
    place-items: center;
    width: 78px;
    height: 78px;
    padding: 5px;
    overflow: hidden;
    background: #171717;
    border: 2px solid var(--af-gold);
    border-radius: 50%;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
    cursor: pointer;
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.ai-faraon-launcher:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 30px rgba(214, 180, 106, 0.22);
}

.ai-faraon-launcher img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    transform: scale(1.4) translateY(-9%);
    transform-origin: center;
}

.ai-faraon-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.ai-faraon-teaser {
    position: absolute;
    right: 0;
    bottom: calc(100% + 14px);
    width: min(270px, calc(100vw - 28px));
    padding: 12px 40px 14px 16px;
    background: var(--af-bg);
    border: 1px solid var(--af-gold);
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: ai-faraon-teaser-in 800ms cubic-bezier(.2, .7, .2, 1) both;
}

.ai-faraon-teaser[hidden],
.ai-faraon-teaser [hidden] {
    display: none;
}

.ai-faraon-teaser::after {
    content: "";
    position: absolute;
    right: 28px;
    bottom: -7px;
    width: 12px;
    height: 12px;
    background: var(--af-bg);
    border-right: 1px solid var(--af-gold);
    border-bottom: 1px solid var(--af-gold);
    transform: rotate(45deg);
}

.ai-faraon-teaser p {
    margin: 0;
}

.ai-faraon-teaser-name {
    margin-bottom: 6px !important;
    color: var(--af-gold);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.ai-faraon-teaser-typing {
    display: flex;
    gap: 5px;
    padding: 6px 0;
}

.ai-faraon-teaser-typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--af-gold);
    animation: ai-faraon-dot 1.1s ease-in-out infinite;
}

.ai-faraon-teaser-typing i:nth-child(2) { animation-delay: .18s; }
.ai-faraon-teaser-typing i:nth-child(3) { animation-delay: .36s; }

.ai-faraon-teaser-msg {
    color: var(--af-text);
    font-size: 14px;
    line-height: 1.5;
    animation: ai-faraon-teaser-in 700ms cubic-bezier(.2, .7, .2, 1) both;
}

.ai-faraon-teaser-cta {
    margin-top: 12px;
    padding: 9px 16px;
    color: #111;
    background: var(--af-gold);
    border: 0;
    border-radius: 999px;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.ai-faraon-teaser-close {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 32px;
    height: 32px;
    padding: 0;
    color: var(--af-gold);
    background: none;
    border: 0;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

@keyframes ai-faraon-dot {
    0%, 60%, 100% { opacity: .3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

@keyframes ai-faraon-teaser-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(.96);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes ai-faraon-appear {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 480px) {
    .ai-faraon-widget {
        right: 14px;
        bottom: 70px;
    }

    .ai-faraon-teaser {
        width: 240px;
        bottom: calc(100% + 10px);
    }

    .ai-faraon-launcher {
        width: 66px;
        height: 66px;
    }

    .ai-faraon-panel {
        position: fixed;
        right: 10px;
        bottom: 146px;
        width: calc(100vw - 20px);
        height: min(600px, calc(100dvh - 170px));
        max-height: calc(100dvh - 170px);
        border-radius: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-faraon-panel {
        animation: none;
    }

    .ai-faraon-launcher {
        transition: none;
    }

    .ai-faraon-teaser,
    .ai-faraon-teaser-msg,
    .ai-faraon-teaser-typing i {
        animation: none;
    }
}
