/* =====================================================
   FIREWORLD CHAT WIDGET
   Navy/Amber design system
   ===================================================== */

#fw-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Toggle Button ── */
#fw-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #E04B26;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(217, 119, 6, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}
#fw-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(217, 119, 6, 0.5);
}
#fw-chat-toggle svg {
    stroke: #231F20;
    width: 32px;
    height: 32px;
    stroke-width: 2;
}
/* Online indicator dot */
#fw-chat-toggle::after {
    content: '';
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 14px;
    height: 14px;
    background: #22C55E;
    border: 2.5px solid #E04B26;
    border-radius: 50%;
}

/* ── Panel ── */
#fw-chat-panel {
    width: 380px;
    height: 520px;
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    box-shadow: 0 12px 48px rgba(15, 23, 42, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#fw-chat-panel.fw-chat-closed {
    display: none;
}
#fw-chat-panel.fw-chat-open {
    display: flex;
}

/* ── Header ── */
#fw-chat-header {
    background: #231F20;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.fw-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #F8FAFC;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.fw-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
#fw-chat-end {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid #3D3835;
    color: #94A3B8;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 500;
    padding: 5px 10px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 3px;
}
#fw-chat-end:hover {
    border-color: #EF4444;
    color: #EF4444;
}
#fw-chat-end svg {
    stroke: currentColor;
}
#fw-chat-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
}
#fw-chat-close svg {
    stroke: #94A3B8;
    transition: stroke 0.2s;
}
#fw-chat-close:hover svg {
    stroke: #F8FAFC;
}

/* ── Gate Form ── */
#fw-chat-gate {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #F8FAFC;
    overflow-y: auto;
}
.fw-gate-inner {
    width: 100%;
    text-align: center;
}
.fw-gate-icon {
    margin-bottom: 16px;
}
.fw-gate-title {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #231F20;
    margin: 0 0 8px;
}
.fw-gate-sub {
    font-size: 13px;
    color: #64748B;
    line-height: 1.6;
    margin: 0 0 24px;
}
.fw-gate-form {
    text-align: left;
}
.fw-gate-form input,
.fw-gate-form select {
    width: 100%;
    padding: 11px 14px;
    margin-bottom: 10px;
    border: 1px solid #E2E8F0;
    background: #FFFFFF;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    color: #231F20;
    border-radius: 4px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
    -webkit-appearance: none;
}
.fw-gate-form input:focus,
.fw-gate-form select:focus {
    border-color: #E04B26;
}
.fw-gate-form input::placeholder {
    color: #94A3B8;
}
.fw-gate-form select {
    color: #94A3B8;
}
.fw-gate-form select:valid {
    color: #231F20;
}
.fw-gate-btn {
    width: 100%;
    padding: 13px;
    margin-top: 4px;
    background: #E04B26;
    color: #231F20;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}
.fw-gate-btn:hover {
    background: #F99C1C;
}
.fw-gate-note {
    text-align: center;
    font-size: 11px;
    color: #94A3B8;
    margin: 12px 0 0;
}

/* ── Chat Body ── */
#fw-chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* ── Messages Area ── */
#fw-chat-messages {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #F8FAFC;
}
#fw-chat-messages::-webkit-scrollbar {
    width: 4px;
}
#fw-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
#fw-chat-messages::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 2px;
}

/* ── Bubbles ── */
.fw-chat-bubble {
    max-width: 85%;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.6;
    word-wrap: break-word;
}
.fw-chat-assistant {
    background: #FFFFFF;
    color: #3D3835;
    border: 1px solid #E2E8F0;
    border-radius: 2px 12px 12px 12px;
    align-self: flex-start;
}
.fw-chat-user {
    background: #231F20;
    color: #F8FAFC;
    border-radius: 12px 2px 12px 12px;
    align-self: flex-end;
}

/* ── Typing Indicator ── */
.fw-chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 18px;
}
.fw-chat-typing span {
    width: 6px;
    height: 6px;
    background: #94A3B8;
    border-radius: 50%;
    display: inline-block;
    animation: fw-typing 1.2s infinite;
}
.fw-chat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}
.fw-chat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}
@keyframes fw-typing {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* ── System Messages ── */
.fw-chat-system {
    text-align: center;
    font-size: 12px;
    color: #64748B;
    background: #F1F5F9;
    border: 1px solid #E2E8F0;
    padding: 12px 16px;
    line-height: 1.5;
    border-radius: 6px;
    margin: 8px 0;
}

/* ── Restart Button ── */
.fw-chat-restart-wrap {
    text-align: center;
    margin: 8px 0;
}
.fw-chat-restart-btn {
    display: inline-block;
    padding: 8px 20px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #E04B26;
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}
.fw-chat-restart-btn:hover {
    background: #E04B26;
    color: #231F20;
    border-color: #E04B26;
}

/* ── Disabled State ── */
#fw-chat-input:disabled {
    background: #F1F5F9;
    color: #94A3B8;
    cursor: not-allowed;
}
#fw-chat-send:disabled {
    background: #94A3B8;
    cursor: not-allowed;
}

/* ── Quick Action Chips ── */
.fw-chat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
}
.fw-chat-chip {
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    color: #E04B26;
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}
.fw-chat-chip:hover {
    background: #E04B26;
    color: #231F20;
    border-color: #E04B26;
}

/* ── Input Area ── */
#fw-chat-input-area {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid #E2E8F0;
    background: #FFFFFF;
    flex-shrink: 0;
    gap: 8px;
    min-height: 62px;
    position: relative;
    z-index: 1;
}
#fw-chat-input {
    flex: 1;
    border: 1px solid #E2E8F0;
    background: #F8FAFC;
    padding: 10px 14px;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    color: #231F20;
    outline: none;
    border-radius: 4px;
    transition: border-color 0.2s;
}
#fw-chat-input:focus {
    border-color: #E04B26;
}
#fw-chat-input::placeholder {
    color: #94A3B8;
}
#fw-chat-send {
    width: 38px;
    height: 38px;
    background: #E04B26;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
#fw-chat-send:hover {
    background: #F99C1C;
}
#fw-chat-send svg {
    stroke: #231F20;
}

/* ── Auto-Prompt Bubble ── */
#fw-chat-prompt {
    position: absolute !important;
    bottom: 72px !important;
    right: 0 !important;
    width: 320px !important;
    background: #231F20 !important;
    border: 1px solid #2D2926 !important;
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.25) !important;
    padding: 0 !important;
    opacity: 0;
    transform: translateY(10px) scale(0.96);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    z-index: 100000 !important;
    display: block !important;
    visibility: visible !important;
    float: none !important;
    margin: 0 !important;
}
#fw-chat-prompt.fw-prompt-visible {
    opacity: 1 !important;
    transform: translateY(0) scale(1) !important;
    pointer-events: auto !important;
}
#fw-chat-prompt.fw-prompt-hiding {
    opacity: 0 !important;
    transform: translateY(10px) scale(0.96) !important;
    pointer-events: none !important;
}
/* Orange top accent */
#fw-chat-prompt::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #E04B26;
}
/* Arrow pointing down to the chat button */
#fw-chat-prompt::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 20px;
    width: 14px;
    height: 14px;
    background: #231F20;
    border-right: 1px solid #2D2926;
    border-bottom: 1px solid #2D2926;
    transform: rotate(45deg);
}
.fw-prompt-content {
    padding: 20px 20px 16px;
}
.fw-prompt-content p {
    font-size: 13px;
    line-height: 1.6;
    color: #CBD5E1;
    margin: 0 0 16px;
}
.fw-prompt-actions {
    display: flex;
    gap: 10px;
}
.fw-prompt-cta {
    flex: 1;
    padding: 9px 16px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: #E04B26;
    color: #231F20;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}
.fw-prompt-cta:hover {
    background: #F99C1C;
}
.fw-prompt-dismiss {
    padding: 9px 14px;
    font-size: 12px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    background: none;
    color: #64748B;
    border: 1px solid #3D3835;
    cursor: pointer;
    transition: all 0.2s;
}
.fw-prompt-dismiss:hover {
    border-color: #64748B;
    color: #94A3B8;
}
.fw-prompt-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: #475569;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}
.fw-prompt-close:hover {
    color: #94A3B8;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    #fw-chat-panel {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        position: fixed;
        bottom: 16px;
        right: 16px;
    }
    #fw-chat-widget {
        bottom: 16px;
        right: 16px;
    }
}
