/* =============================================================================
   SlapEFT Live Chat Widget
   Self-hosted, privacy-first live chat styling
============================================================================= */

.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Toggle Button */
.chat-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent, #d4a574);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bg-primary, #0c0c0c);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.chat-toggle:active {
    transform: scale(0.98);
}

.chat-toggle svg {
    width: 24px;
    height: 24px;
}

/* Notification Badge */
.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: badge-pulse 2s infinite;
}

@keyframes badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 350px;
    height: 480px;
    background: var(--bg-card, #1a1a1a);
    border: 1px solid var(--border, #2a2a2a);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    animation: chat-slide-up 0.3s ease-out;
}

@keyframes chat-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.chat-header-title span {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary, #e5e5e5);
}

.chat-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
}

.chat-status.offline {
    background: #737373;
}

.chat-header button {
    background: none;
    border: none;
    color: var(--text-secondary, #737373);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    transition: color 0.15s;
}

.chat-header button:hover {
    color: var(--text-primary, #e5e5e5);
}

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

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border, #2a2a2a);
    border-radius: 3px;
}

/* Message Bubble */
.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    animation: msg-appear 0.2s ease-out;
}

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

.chat-msg-visitor {
    align-self: flex-end;
    background: var(--accent, #d4a574);
    color: var(--bg-primary, #0c0c0c);
    border-bottom-right-radius: 4px;
}

.chat-msg-admin {
    align-self: flex-start;
    background: var(--bg-elevated, #2a2a2a);
    color: var(--text-primary, #e5e5e5);
    border-bottom-left-radius: 4px;
}

.chat-msg-content {
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
}

.chat-msg-time {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 4px;
}

/* System Messages */
.chat-msg-system {
    align-self: center;
    background: none;
    color: var(--text-muted, #525252);
    font-size: 12px;
    padding: 8px 0;
}

/* Typing Indicator */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: var(--text-secondary, #737373);
    font-size: 12px;
}

.chat-typing-dots {
    display: flex;
    gap: 4px;
}

.chat-typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-secondary, #737373);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite;
}

.chat-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Input Form */
.chat-form {
    padding: 12px;
    border-top: 1px solid var(--border, #2a2a2a);
    display: flex;
    gap: 8px;
    background: var(--bg-card, #1a1a1a);
}

.chat-form input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border, #2a2a2a);
    border-radius: 8px;
    background: var(--bg-primary, #0c0c0c);
    color: var(--text-primary, #e5e5e5);
    font-size: 14px;
    transition: border-color 0.15s;
}

.chat-form input:focus {
    outline: none;
    border-color: var(--accent, #d4a574);
}

.chat-form input::placeholder {
    color: var(--text-muted, #525252);
}

.chat-form button {
    padding: 10px 14px;
    background: var(--accent, #d4a574);
    border: none;
    border-radius: 8px;
    color: var(--bg-primary, #0c0c0c);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.chat-form button:hover {
    background: var(--accent-dark, #b8956a);
}

.chat-form button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-form button svg {
    width: 20px;
    height: 20px;
}

/* Welcome Screen */
.chat-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
}

.chat-welcome h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text-primary, #e5e5e5);
}

.chat-welcome p {
    font-size: 14px;
    color: var(--text-secondary, #737373);
    margin-bottom: 24px;
    line-height: 1.5;
}

.chat-welcome button {
    padding: 12px 24px;
    background: var(--accent, #d4a574);
    color: var(--bg-primary, #0c0c0c);
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.chat-welcome button:hover {
    background: var(--accent-dark, #b8956a);
}

/* Connection Status */
.chat-connection {
    padding: 8px 16px;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    font-size: 12px;
    text-align: center;
    border-bottom: 1px solid rgba(239, 68, 68, 0.2);
}

.chat-connection.reconnecting {
    background: rgba(251, 191, 36, 0.1);
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.2);
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .chat-widget {
        bottom: 16px;
        right: 16px;
    }

    .chat-toggle {
        width: 52px;
        height: 52px;
    }

    .chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        animation: chat-fade-in 0.2s ease-out;
    }

    @keyframes chat-fade-in {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    .chat-header {
        padding: 16px 20px;
    }

    .chat-messages {
        padding: 16px 20px;
    }

    .chat-form {
        padding: 16px 20px;
        /* Account for iOS safe area */
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}

/* Dark mode adjustments (already dark by default) */
@media (prefers-color-scheme: light) {
    .chat-widget {
        /* Override for light mode visitors - keep dark theme for consistency */
        --bg-primary: #0c0c0c;
        --bg-card: #1a1a1a;
        --bg-elevated: #222222;
        --text-primary: #e5e5e5;
        --text-secondary: #737373;
        --border: #2a2a2a;
        --accent: #d4a574;
    }
}
