/* ====================================================
   CreaNext Chat Widget - AI + Live Support
   ==================================================== */

:root {
    --chat-bg: #111118;
    --chat-header-bg: #0a0a12;
    --chat-accent: #3b82f6;
    --chat-accent-glow: rgba(59, 130, 246, 0.3);
    --chat-text: #e2e8f0;
    --chat-user-msg: linear-gradient(135deg, #3b82f6, #6366f1);
    --chat-bot-msg: #1e1e2e;
    --chat-agent-msg: #1a2e1a;
    --chat-border: rgba(255, 255, 255, 0.08);
    --chat-input-bg: rgba(255, 255, 255, 0.04);
}

/* ── Float Button ── */
.chat-widget-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 58px;
    height: 58px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px var(--chat-accent-glow);
    z-index: 10000;
    transition: all 0.3s ease;
    border: none;
    animation: chatPulse 3s ease-in-out infinite;
}

@keyframes chatPulse {
    0%, 100% { box-shadow: 0 4px 20px var(--chat-accent-glow); }
    50% { box-shadow: 0 4px 30px rgba(99, 102, 241, 0.5); }
}

.chat-widget-btn:hover {
    transform: scale(1.1);
    animation: none;
}

.chat-widget-btn i {
    font-size: 22px;
    color: white;
}

.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #0a0a0f;
    animation: badgeBounce 0.4s ease;
}

@keyframes badgeBounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* ── Chat Window ── */
.chat-window {
    position: fixed;
    bottom: 94px;
    right: 24px;
    width: 380px;
    height: 560px;
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    z-index: 10000;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-window.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ── Header ── */
.chat-header {
    padding: 14px 16px;
    background: var(--chat-header-bg);
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-avatar i {
    font-size: 16px;
    color: white;
}

.chat-header h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
}

.chat-header #statusText {
    font-size: 0.7rem;
    color: #22c55e;
    font-weight: 500;
}

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

.chat-header-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

/* ── Mode Bar ── */
.chat-mode-bar {
    display: flex;
    padding: 6px;
    gap: 4px;
    background: var(--chat-header-bg);
    border-bottom: 1px solid var(--chat-border);
}

.mode-tab {
    flex: 1;
    padding: 7px 12px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.mode-tab:hover {
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.04);
}

.mode-tab.active {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.mode-tab i {
    font-size: 12px;
}

/* ── Messages Area ── */
.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* ── Message Bubbles ── */
.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.85rem;
    line-height: 1.5;
    word-wrap: break-word;
    animation: msgSlide 0.3s ease;
    position: relative;
}

@keyframes msgSlide {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message .msg-content {
    white-space: pre-wrap;
}

.message .msg-content a {
    color: #60a5fa;
    text-decoration: none;
}

.message .msg-content a:hover {
    text-decoration: underline;
}

.message .msg-time {
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.3);
    margin-top: 4px;
    text-align: right;
}

.message.bot, .message.agent {
    background: var(--chat-bot-msg);
    color: var(--chat-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.agent {
    background: var(--chat-agent-msg);
    border-left: 3px solid #22c55e;
}

.agent-label {
    font-size: 0.65rem;
    color: #22c55e;
    font-weight: 600;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message.user {
    background: var(--chat-user-msg);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.user .msg-time {
    color: rgba(255, 255, 255, 0.5);
}

/* ── Typing Indicator ── */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 14px 18px !important;
}

.typing-indicator .dot {
    width: 8px;
    height: 8px;
    background: #64748b;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Quick Replies ── */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0;
    animation: msgSlide 0.3s ease;
}

.quick-reply-btn {
    padding: 6px 14px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #60a5fa;
    border-radius: 20px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.quick-reply-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
    transform: translateY(-1px);
}

/* ── Input Area ── */
.chat-input-area {
    padding: 12px 14px;
    border-top: 1px solid var(--chat-border);
    display: flex;
    gap: 8px;
    background: var(--chat-header-bg);
}

.chat-input {
    flex: 1;
    background: var(--chat-input-bg);
    border: 1px solid var(--chat-border);
    border-radius: 24px;
    padding: 10px 16px;
    color: white;
    outline: none;
    font-family: inherit;
    font-size: 0.85rem;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: rgba(59, 130, 246, 0.4);
}

.chat-input::placeholder {
    color: #475569;
}

.chat-send-btn {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--chat-accent-glow);
}

.chat-send-btn i {
    font-size: 14px;
}

/* ── Footer ── */
.chat-footer {
    padding: 6px;
    text-align: center;
    font-size: 0.6rem;
    color: #334155;
    border-top: 1px solid var(--chat-border);
    background: var(--chat-header-bg);
}

.chat-footer strong {
    color: #475569;
}

/* ── Ticket Badge ── */
.ticket-badge {
    font-size: 0.65rem;
    background: linear-gradient(135deg, #eab308, #f59e0b);
    color: black;
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: 6px;
    display: inline-block;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* ── Mobile ── */
@media (max-width: 480px) {
    .chat-window {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
        max-height: 100dvh;
    }

    .chat-widget-btn {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }

    .chat-widget-btn i {
        font-size: 20px;
    }
}

/* ── Feedback Form ── */
.feedback-form {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 14px;
    padding: 18px;
    margin: 12px 8px;
    text-align: center;
}

.fb-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 10px;
}

.fb-stars {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 12px;
}

.fb-star {
    font-size: 28px;
    color: #475569;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
}

.fb-star:hover,
.fb-star.active {
    color: #eab308;
    transform: scale(1.2);
}

.fb-comment {
    width: 100%;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    color: #e2e8f0;
    padding: 8px 10px;
    font-size: 0.78rem;
    font-family: inherit;
    resize: none;
    margin-bottom: 10px;
}

.fb-comment:focus {
    outline: none;
    border-color: #6366f1;
}

.fb-submit {
    width: 100%;
    padding: 9px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 6px;
    transition: opacity 0.2s;
}

.fb-submit:hover { opacity: 0.9; }

.fb-skip {
    background: none;
    border: none;
    color: #64748b;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 4px 8px;
}

.fb-skip:hover { color: #94a3b8; }

/* New Chat Button */
.new-chat-btn {
    padding: 10px 22px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.new-chat-btn:hover {
    transform: scale(1.04);
    opacity: 0.9;
}

.new-chat-btn i { margin-right: 6px; }

/* Disabled input state */
#chatInput:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #1e293b;
}