/* =========================================================
   AntonMarketer AI Chat Widget  –  amchat.css
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

/* ── Variables ── */
#amchat-root {
    --am-accent:        #e84c1f;          /* AntonMarketer orange-red */
    --am-accent-dim:    rgba(232,76,31,.12);
    --am-accent-glow:   rgba(232,76,31,.07);
    --am-bg:            #0f0f10;
    --am-surface:       #181819;
    --am-surface2:      #222224;
    --am-border:        #2c2c2e;
    --am-border2:       #3a3a3c;
    --am-text:          #f0f0f0;
    --am-muted:         #888;
    --am-dim:           #555;
    --am-radius:        14px;
    --am-panel-w:       370px;
    --am-panel-h:       540px;
    --am-z:             999999;
    font-family: 'DM Sans', sans-serif;
}

/* ── Reset inside root ── */
#amchat-root * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: inherit;
}

/* ── Trigger button ── */
#amchat-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: var(--am-z);
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--am-accent);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 13px 20px 13px 16px;
    cursor: pointer;
    box-shadow: 0 4px 24px rgba(232,76,31,.4), 0 2px 8px rgba(0,0,0,.4);
    transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease, opacity .2s;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .01em;
    white-space: nowrap;
    user-select: none;
}

#amchat-trigger:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 8px 32px rgba(232,76,31,.5), 0 2px 8px rgba(0,0,0,.4);
}

#amchat-trigger:active { transform: scale(.97); }

#amchat-trigger.amchat-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(16px) scale(.9);
}

.amchat-trigger-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.amchat-trigger-label {
    font-size: 14px;
    font-weight: 600;
}

/* Pulse ring */
.amchat-trigger-pulse {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 10px;
    height: 10px;
    background: #4ade80;
    border-radius: 50%;
    border: 2px solid var(--am-accent);
}

.amchat-trigger-pulse::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: rgba(74,222,128,.35);
    animation: amchat-ring 2s ease-out infinite;
}

@keyframes amchat-ring {
    0%   { transform: scale(.6); opacity: 1; }
    100% { transform: scale(2);  opacity: 0; }
}

/* ── Panel ── */
#amchat-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    z-index: var(--am-z);
    width: var(--am-panel-w);
    height: var(--am-panel-h);
    background: var(--am-bg);
    border: 1px solid var(--am-border);
    border-radius: var(--am-radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow:
        0 24px 64px rgba(0,0,0,.7),
        0 0 0 1px rgba(255,255,255,.04) inset,
        0 1px 0 rgba(255,255,255,.06) inset;
    transform-origin: bottom right;

    /* Hidden state */
    opacity: 0;
    pointer-events: none;
    transform: scale(.92) translateY(16px);
    transition: opacity .22s ease, transform .22s cubic-bezier(.34,1.56,.64,1);
}

#amchat-panel.amchat-open {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1) translateY(0);
}

/* ── Header ── */
#amchat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--am-border);
    background: var(--am-surface);
    flex-shrink: 0;
}

.amchat-header-identity {
    display: flex;
    align-items: center;
    gap: 10px;
}

.amchat-avatar-sm {
    width: 32px;
    height: 32px;
    background: var(--am-accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

.amchat-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.amchat-header-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--am-text);
    line-height: 1;
}

.amchat-header-status {
    font-size: 11px;
    color: var(--am-muted);
    display: flex;
    align-items: center;
    gap: 5px;
    line-height: 1;
}

.amchat-status-dot {
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
    flex-shrink: 0;
    animation: amchat-blink 3s ease-in-out infinite;
}

@keyframes amchat-blink {
    0%, 80%, 100% { opacity: 1; }
    40%            { opacity: .4; }
}

.amchat-header-actions {
    display: flex;
    gap: 4px;
}

.amchat-header-actions button {
    background: none;
    border: none;
    color: var(--am-muted);
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}

.amchat-header-actions button:hover {
    background: var(--am-surface2);
    color: var(--am-text);
}

/* ── Messages ── */
#amchat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#amchat-messages::-webkit-scrollbar { width: 3px; }
#amchat-messages::-webkit-scrollbar-track { background: transparent; }
#amchat-messages::-webkit-scrollbar-thumb { background: var(--am-border2); border-radius: 3px; }

/* Message rows */
.amchat-msg {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    animation: amchat-up .2s ease both;
    padding: 2px 0;
}

@keyframes amchat-up {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.amchat-msg-avatar {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    margin-top: 2px;
    font-family: 'DM Mono', monospace;
}

.amchat-msg-avatar.agent {
    background: var(--am-accent);
    color: #fff;
}

.amchat-msg-avatar.user {
    background: var(--am-surface2);
    color: var(--am-muted);
    border: 1px solid var(--am-border2);
}

.amchat-msg-body {
    flex: 1;
    min-width: 0;
}

.amchat-msg-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--am-muted);
    margin-bottom: 4px;
    letter-spacing: .02em;
}

.amchat-msg-text {
    font-size: 13.5px;
    line-height: 1.68;
    color: var(--am-text);
    white-space: pre-wrap;
    word-break: break-word;
}

/* Inline formatting */
.amchat-msg-text a {
    color: var(--am-accent);
    text-decoration: none;
    border-bottom: 1px solid rgba(232,76,31,.3);
}
.amchat-msg-text a:hover { border-color: var(--am-accent); }

/* ── Typing indicator ── */
.amchat-typing {
    display: flex;
    gap: 4px;
    padding: 4px 0 2px;
    align-items: center;
}

.amchat-dot {
    width: 5px;
    height: 5px;
    background: var(--am-dim);
    border-radius: 50%;
    animation: amchat-pulse 1.3s ease-in-out infinite;
}
.amchat-dot:nth-child(2) { animation-delay: .18s; }
.amchat-dot:nth-child(3) { animation-delay: .36s; }

@keyframes amchat-pulse {
    0%, 80%, 100% { opacity: .25; transform: scale(.75); }
    40%            { opacity: 1;   transform: scale(1); }
}

/* ── Input area ── */
#amchat-input-area {
    padding: 10px 14px 12px;
    border-top: 1px solid var(--am-border);
    background: var(--am-surface);
    flex-shrink: 0;
}

.amchat-input-wrap {
    position: relative;
}

#amchat-input {
    width: 100%;
    background: var(--am-surface2);
    border: 1px solid var(--am-border2);
    border-radius: 10px;
    padding: 11px 44px 11px 14px;
    color: var(--am-text);
    font-size: 13.5px;
    line-height: 1.5;
    resize: none;
    outline: none;
    min-height: 44px;
    max-height: 140px;
    overflow-y: auto;
    transition: border-color .2s, box-shadow .2s;
}

#amchat-input::placeholder { color: var(--am-dim); }

#amchat-input:focus {
    border-color: var(--am-accent);
    box-shadow: 0 0 0 3px var(--am-accent-glow);
}

#amchat-send {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 28px;
    height: 28px;
    background: var(--am-accent);
    border: none;
    border-radius: 7px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: opacity .2s, transform .1s;
    flex-shrink: 0;
}

#amchat-send:hover { opacity: .85; }
#amchat-send:active { transform: scale(.9); }
#amchat-send:disabled { opacity: .3; cursor: not-allowed; }

.amchat-footer-hint {
    font-size: 10.5px;
    color: var(--am-dim);
    text-align: center;
    margin-top: 7px;
    letter-spacing: .02em;
}

/* ── Mobile responsive ── */
@media (max-width: 480px) {
    #amchat-panel {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 82px;
        height: calc(100dvh - 100px);
        max-height: 580px;
        border-radius: 16px;
    }

    #amchat-trigger {
        right: 14px;
        bottom: 14px;
    }
}
