/**
 * Live Chat Widget Styles
 * Modern floating chat widget with smooth animations
 * Theme: Deep Blue & Gold
 */

/* CSS Variables */
:root {
    --chat-primary: #0f172a; /* Deep Blue */
    --chat-primary-dark: #020617; /* Darker Slate */
    --chat-accent: #bd9812; /* Gold */
    --chat-success: #10b981;
    --chat-warning: #f59e0b;
    --chat-danger: #ef4444;
    --chat-bg: #ffffff;
    --chat-text: #1e293b;
    --chat-text-muted: #64748b;
    --chat-border: #e2e8f0;
    --chat-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --chat-radius: 16px;
}

/* Chat Widget Container */
.chat-widget-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Chat Toggle Button */
.chat-toggle-btn {
    width: 64px;
    height: 64px;
    border-radius: 20px; /* Squircle */
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    border: 2px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.chat-toggle-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 35px -5px rgba(15, 23, 42, 0.5);
}

.chat-toggle-btn svg {
    width: 32px;
    height: 32px;
    fill: white; /* Gold icon */
    transition: transform 0.3s ease;
}

.chat-toggle-btn.active {
    border-radius: 50%; /* Circle when active */
    transform: rotate(90deg);
}

.chat-toggle-btn.active svg.icon-chat {
    display: none;
}

.chat-toggle-btn.active svg.icon-close {
    display: block;
}

.chat-toggle-btn svg.icon-close {
    display: none;
}

/* Unread Badge */
.chat-unread-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--chat-danger);
    color: white;
    font-size: 12px;
    font-weight: 700;
    min-width: 24px;
    height: 24px;
    border-radius: 12px;
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: bounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bounceIn {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 90px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 140px);
    background: var(--chat-bg);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    border: 1px solid var(--chat-border);
}

.chat-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Chat Header */
.chat-header {
    background: var(--chat-primary);
    color: white;
    padding: 24px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

/* Gold accent line */
.chat-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(to right, var(--chat-accent), #f59e0b);
}

.chat-header-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 4px 0;
    letter-spacing: -0.5px;
}

.chat-header-status {
    font-size: 13px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.chat-header-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chat-success);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.chat-header-status .status-dot.offline {
    background: var(--chat-text-muted);
    box-shadow: none;
}

/* Chat Body */
.chat-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background-color: #f8fafc; /* Very light slate */
}

/* Pre-Chat Form */
.chat-prechat-form {
    padding: 32px;
    height: 100%;
    overflow-y: auto;
    background: white;
}

.chat-prechat-form h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--chat-text);
    margin: 0 0 8px 0;
}

.chat-prechat-form p {
    font-size: 14px;
    color: var(--chat-text-muted);
    margin: 0 0 24px 0;
    line-height: 1.5;
}

.chat-form-group {
    margin-bottom: 16px;
}

.chat-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--chat-text);
    margin-bottom: 8px;
}

.chat-form-group input,
.chat-form-group select,
.chat-form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    font-size: 14px;
    color: var(--chat-text);
    background: #f8fafc;
    transition: all 0.2s;
    box-sizing: border-box;
}

.chat-form-group input:focus,
.chat-form-group select:focus,
.chat-form-group textarea:focus {
    outline: none;
    border-color: var(--chat-accent);
    background: white;
    box-shadow: 0 0 0 4px rgba(189, 152, 18, 0.1);
}

.chat-form-group input::placeholder {
    color: #cbd5e1;
}

.chat-start-btn {
    width: 100%;
    padding: 14px;
    background: var(--chat-primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.chat-start-btn:hover {
    background: var(--chat-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: none;
    flex-direction: column;
    gap: 16px;
}

.chat-messages.active {
    display: flex;
}

.chat-message {
    max-width: 85%;
    animation: messageIn 0.3s ease;
}

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

.chat-message.visitor {
    align-self: flex-end;
}

.chat-message.agent {
    align-self: flex-start;
}

.chat-message-bubble {
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.chat-message.visitor .chat-message-bubble {
    background: var(--chat-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.agent .chat-message-bubble {
    background: white;
    color: var(--chat-text);
    border: 1px solid var(--chat-border);
    border-bottom-left-radius: 4px;
}

.chat-message-time {
    font-size: 11px;
    color: var(--chat-text-muted);
    margin-top: 4px;
    padding: 0 4px;
    font-weight: 500;
}

.chat-message.visitor .chat-message-time {
    text-align: right;
}

/* System Message */
.chat-message.system {
    align-self: center;
    max-width: 90%;
    margin: 8px 0;
}

.chat-message.system .chat-message-bubble {
    background: rgba(100, 116, 139, 0.1);
    color: var(--chat-text-muted);
    font-size: 12px;
    padding: 6px 12px;
    text-align: center;
    border-radius: 20px;
    box-shadow: none;
}

/* Typing Indicator */
.chat-typing-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    font-size: 12px;
    color: var(--chat-text-muted);
    background: rgba(255,255,255,0.5);
}

.chat-typing-indicator.active {
    display: flex;
}

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

.chat-typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--chat-text-muted);
    border-radius: 50%;
    animation: typingDot 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 typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Chat Input */
.chat-input-container {
    padding: 16px;
    background: white;
    border-top: 1px solid var(--chat-border);
    display: none;
    flex-shrink: 0;
}

.chat-input-container.active {
    display: block;
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: #f8fafc;
    border: 1px solid var(--chat-border);
    border-radius: 24px;
    padding: 6px;
    transition: border-color 0.2s, background 0.2s;
}

.chat-input-wrapper:focus-within {
    border-color: var(--chat-accent);
    background: white;
    box-shadow: 0 0 0 3px rgba(189, 152, 18, 0.1);
}

.chat-input-field {
    flex: 1;
    padding: 10px 12px;
    border: none;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    line-height: 1.4;
    color: var(--chat-text);
    background: transparent;
}

.chat-input-field:focus {
    outline: none;
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--chat-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-bottom: 2px;
}

.chat-send-btn:hover {
    transform: scale(1.1);
    background: var(--chat-accent);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    background: var(--chat-text-muted);
}

.chat-send-btn svg {
    width: 16px;
    height: 16px;
    fill: white;
    margin-left: 2px; /* Visual alignment */
}

/* Offline View */
.chat-offline {
    padding: 32px;
    display: none;
    overflow-y: auto;
    flex: 1;
    background: white;
}

.chat-offline.active {
    display: block;
}

.chat-offline-message {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.chat-offline-message svg {
    width: 24px;
    height: 24px;
    fill: var(--chat-warning);
    flex-shrink: 0;
}

.chat-offline-message p {
    margin: 0;
    font-size: 14px;
    color: #92400e;
    line-height: 1.5;
}

/* Chat Ended */
.chat-ended {
    padding: 40px 24px;
    text-align: center;
    display: none;
    height: 100%;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: white;
}

.chat-ended.active {
    display: flex;
}

.chat-ended svg {
    width: 64px; /* Fixed size */
    height: 64px;
    fill: var(--chat-success);
    margin-bottom: 24px;
    display: block;
}

.chat-ended h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--chat-text);
    margin: 0 0 8px 0;
}

.chat-ended p {
    font-size: 14px;
    color: var(--chat-text-muted);
    margin: 0 0 32px 0;
}

.chat-rating {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 32px;
}

.chat-rating-star {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s;
}

.chat-rating-star:hover {
    transform: scale(1.1);
}

.chat-rating-star svg {
    width: 100%;
    height: 100%;
    fill: #e2e8f0;
    transition: fill 0.2s;
    margin: 0; /* Reset margin */
}

.chat-rating-star.active svg,
.chat-rating-star:hover svg {
    fill: var(--chat-warning);
}

.chat-new-chat-btn {
    padding: 12px 24px;
    background: white;
    color: var(--chat-primary);
    border: 2px solid var(--chat-primary);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-new-chat-btn:hover {
    background: var(--chat-primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .chat-widget-container {
        bottom: 16px;
        right: 16px;
    }
    
    .chat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 0;
    }
    
    .chat-toggle-btn {
        width: 56px;
        height: 56px;
    }
}

/* Loading Spinner */
.chat-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
