/**
 * Chat Support Widget Styles
 * Modern, clean design with smooth animations
 */

/* ==================== CHAT WIDGET ROOT ==================== */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --chat-primary: #86EFAC;
    --chat-primary-dark: #4ADE80;
    --chat-bg: #0f1419;
    --chat-surface: #1a1f2e;
    --chat-surface-hover: #252b3d;
    --chat-text: #f1f5f9;
    --chat-text-muted: #94a3b8;
    --chat-border: rgba(148, 163, 184, 0.1);
    --chat-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --chat-accent: #60A5FA;
    --chat-success: #4ADE80;
    --chat-warning: #FBBF24;
    --chat-error: #F87171;
}

/* ==================== CHAT TOGGLE BUTTON ==================== */
.chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(134, 239, 172, 0.3), 0 8px 40px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    animation: chat-pulse 2s infinite;
}

@keyframes chat-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(134, 239, 172, 0.3), 0 0 0 0 rgba(134, 239, 172, 0.4); }
    50% { box-shadow: 0 4px 20px rgba(134, 239, 172, 0.3), 0 0 0 15px rgba(134, 239, 172, 0); }
}

.chat-toggle:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 6px 30px rgba(134, 239, 172, 0.4), 0 0 0 0 rgba(134, 239, 172, 0);
}

.chat-toggle:active {
    transform: scale(0.95);
}

.chat-toggle svg {
    width: 28px;
    height: 28px;
    color: #0f1419;
    transition: transform 0.3s ease;
}

.chat-toggle.active svg {
    transform: rotate(90deg);
}

/* Notification badge */
.chat-toggle-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background: #F87171;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: white;
    border: 2px solid var(--chat-bg);
    animation: badge-bounce 0.5s ease;
}

@keyframes badge-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* ==================== CHAT WINDOW ==================== */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: var(--chat-bg);
    border-radius: 20px;
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--chat-border);
}

.chat-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ==================== CHAT HEADER ==================== */
.chat-header {
    background: linear-gradient(135deg, var(--chat-surface) 0%, #252b3d 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--chat-border);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.chat-avatar::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: var(--chat-success);
    border-radius: 50%;
    border: 2px solid var(--chat-surface);
}

.chat-avatar svg {
    width: 22px;
    height: 22px;
    color: #0f1419;
}

.chat-title {
    display: flex;
    flex-direction: column;
}

.chat-title h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--chat-text);
}

.chat-title span {
    font-size: 12px;
    color: var(--chat-success);
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-header-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--chat-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-header-btn:hover {
    background: var(--chat-surface-hover);
    color: var(--chat-text);
}

.chat-header-btn svg {
    width: 18px;
    height: 18px;
}

/* ==================== CHAT MESSAGES AREA ==================== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--chat-surface-hover) transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--chat-surface-hover);
    border-radius: 3px;
}

/* Welcome message */
.chat-welcome {
    text-align: center;
    padding: 20px 10px;
}

.chat-welcome-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--chat-surface) 0%, #252b3d 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-welcome-icon svg {
    width: 30px;
    height: 30px;
    color: var(--chat-primary);
}

.chat-welcome h4 {
    margin: 0 0 8px;
    font-size: 16px;
    color: var(--chat-text);
}

.chat-welcome p {
    margin: 0;
    font-size: 13px;
    color: var(--chat-text-muted);
    line-height: 1.6;
}

/* Message bubbles */
.chat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: message-appear 0.3s ease;
}

@keyframes message-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
    color: #0f1419;
    border-bottom-right-radius: 4px;
}

.chat-message.operator {
    align-self: flex-start;
    background: var(--chat-surface);
    color: var(--chat-text);
    border-bottom-left-radius: 4px;
}

.chat-message.system {
    align-self: center;
    background: transparent;
    color: var(--chat-text-muted);
    font-size: 12px;
    padding: 8px 16px;
    max-width: 100%;
}

.chat-message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
    display: block;
}

.chat-message-link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
}

.chat-message-link:hover {
    opacity: 0.85;
}

.chat-message-typing {
    display: flex;
    gap: 4px;
    padding: 16px 20px;
}

.chat-message-typing span {
    width: 8px;
    height: 8px;
    background: var(--chat-text-muted);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

.chat-message-typing span:nth-child(1) { animation-delay: -0.32s; }
.chat-message-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ==================== CHAT INPUT AREA ==================== */
.chat-input-area {
    padding: 16px 20px 20px;
    background: var(--chat-surface);
    border-top: 1px solid var(--chat-border);
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--chat-text);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    outline: none;
    transition: all 0.2s ease;
}

.chat-input:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(134, 239, 172, 0.1);
}

.chat-input::placeholder {
    color: var(--chat-text-muted);
}

.chat-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--chat-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    background: var(--chat-primary-dark);
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-send-btn svg {
    width: 20px;
    height: 20px;
    color: #0f1419;
}

.chat-input-status {
    font-size: 11px;
    color: var(--chat-text-muted);
    margin-top: 8px;
    text-align: center;
}

/* ==================== CHAT NOTIFICATION ==================== */
.chat-notification {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 320px;
    background: var(--chat-surface);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--chat-shadow);
    border: 1px solid var(--chat-border);
    animation: notification-slide 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes notification-slide {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chat-notification.hide {
    animation: notification-hide 0.3s ease forwards;
}

@keyframes notification-hide {
    to {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
}

.chat-notification-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.chat-notification-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-notification-avatar svg {
    width: 22px;
    height: 22px;
    color: #0f1419;
}

.chat-notification-title {
    flex: 1;
}

.chat-notification-title h4 {
    margin: 0 0 2px;
    font-size: 15px;
    color: var(--chat-text);
}

.chat-notification-title span {
    font-size: 12px;
    color: var(--chat-success);
}

.chat-notification-close {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: var(--chat-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-notification-close:hover {
    background: var(--chat-surface-hover);
    color: var(--chat-text);
}

.chat-notification-close svg {
    width: 16px;
    height: 16px;
}

.chat-notification-text {
    font-size: 13px;
    color: var(--chat-text-muted);
    line-height: 1.5;
    margin-bottom: 12px;
}

.chat-notification-btn {
    width: 100%;
    padding: 12px;
    background: var(--chat-primary);
    border: none;
    border-radius: 10px;
    color: #0f1419;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-notification-btn:hover {
    background: var(--chat-primary-dark);
    transform: translateY(-1px);
}

/* ==================== CHAT STATUSES ==================== */
.chat-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px 20px;
    color: var(--chat-text-muted);
    font-size: 14px;
}

.chat-status-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--chat-surface-hover);
    border-top-color: var(--chat-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.chat-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--chat-error);
}

.chat-error svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 480px) {
    .chat-widget {
        bottom: 10px;
        right: 10px;
    }
    
    .chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: 0;
        border-radius: 16px;
    }
    
    .chat-notification {
        width: calc(100vw - 20px);
    }
    
    .chat-toggle {
        width: 54px;
        height: 54px;
    }
    
    .chat-toggle svg {
        width: 24px;
        height: 24px;
    }
}

/* ==================== DARK THEME ADJUSTMENTS ==================== */
@media (prefers-color-scheme: light) {
    .chat-widget {
        --chat-bg: #ffffff;
        --chat-surface: #f8fafc;
        --chat-surface-hover: #e2e8f0;
        --chat-text: #1e293b;
        --chat-text-muted: #64748b;
        --chat-border: rgba(148, 163, 184, 0.2);
        --chat-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    }
    
    .chat-message.operator {
        background: #f1f5f9;
    }
    
    .chat-avatar::after {
        border-color: #ffffff;
    }
}
