/* ============================================
   LIVE CHAT WIDGET - DARK THEME WITH RED ACCENT
   Premium Design - Professional Look
============================================ */

:root {
    --chat-primary: #ff4d4d;
    --chat-primary-dark: #cc0000;
    --chat-primary-light: #ff6b6b;
    --chat-bg-dark: #1a1a1a;
    --chat-bg-darker: #0d0d0d;
    --chat-bg-card: #2d2d2d;
    --chat-bg-input: #3d3d3d;
    --chat-text-primary: #ffffff;
    --chat-text-secondary: #b3b3b3;
    --chat-border: #404040;
    --chat-shadow: 0 8px 30px rgba(255, 0, 0, 0.2);
    --chat-gradient: linear-gradient(135deg, #ff4d4d 0%, #cc0000 100%);
}

.chat-widget-container {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 999999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ========== CHAT BUTTON ========== */
.chat-widget-button {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: var(--chat-gradient);
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 6px 20px rgba(255, 77, 77, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    animation: widgetPulse 2s infinite;
}

@keyframes widgetPulse {
    0% { box-shadow: 0 6px 20px rgba(255, 77, 77, 0.4); }
    50% { box-shadow: 0 6px 30px rgba(255, 77, 77, 0.8); }
    100% { box-shadow: 0 6px 20px rgba(255, 77, 77, 0.4); }
}

.chat-widget-button:hover {
    transform: scale(1.15) rotate(5deg);
    border-color: rgba(255, 255, 255, 0.4);
}

.chat-widget-button i {
    font-size: 30px;
    color: white;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.3));
}

.chat-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    border: 2px solid var(--chat-bg-dark);
    animation: badgePulse 1.5s infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ========== CHAT BOX ========== */
.chat-widget-box {
    position: absolute;
    bottom: 85px;
    right: 0;
    width: 380px;
    height: 550px;
    background: var(--chat-bg-dark);
    border-radius: 20px;
    box-shadow: var(--chat-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 77, 77, 0.3);
    backdrop-filter: blur(10px);
}

.chat-widget-box.active {
    display: flex;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ========== CHAT HEADER ========== */
.chat-widget-header {
    background: var(--chat-gradient);
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.chat-header-text {
    flex: 1;
}

.chat-header-text h5 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 700;
    color: white;
    letter-spacing: 0.5px;
}

.chat-header-text p {
    margin: 0;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-online-indicator {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
    animation: onlineBlink 2s infinite;
}

@keyframes onlineBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.8;
    transition: all 0.3s;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-close-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* ========== CHAT MESSAGES AREA ========== */
.chat-widget-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: var(--chat-bg-darker);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-widget-messages::-webkit-scrollbar {
    width: 5px;
}

.chat-widget-messages::-webkit-scrollbar-track {
    background: var(--chat-bg-dark);
}

.chat-widget-messages::-webkit-scrollbar-thumb {
    background: var(--chat-primary);
    border-radius: 10px;
}

.chat-widget-messages::-webkit-scrollbar-thumb:hover {
    background: var(--chat-primary-dark);
}

/* ========== CHAT MESSAGES ========== */
.chat-message {
    display: flex;
    flex-direction: column;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    padding: 0 5px;
}

.chat-message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.chat-message-avatar.admin {
    background: var(--chat-gradient);
}

.chat-message-avatar.user {
    background: linear-gradient(135deg, #2c3e50, #3498db);
}

.chat-message-name {
    font-weight: 600;
    font-size: 13px;
}

.chat-message-name.admin {
    color: var(--chat-primary);
}

.chat-message-name.user {
    color: #3498db;
}

.chat-message-time {
    font-size: 10px;
    color: var(--chat-text-secondary);
    margin-left: auto;
}

.chat-message-bubble {
    background: var(--chat-bg-card);
    padding: 12px 16px;
    border-radius: 18px;
    border-top-left-radius: 4px;
    font-size: 13px;
    color: var(--chat-text-primary);
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    margin-left: 38px;
    position: relative;
    word-wrap: break-word;
    border: 1px solid rgba(255, 77, 77, 0.2);
}

.chat-message-bubble::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 12px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 8px 8px 0;
    border-color: transparent var(--chat-bg-card) transparent transparent;
}

.chat-message.user .chat-message-bubble {
    background: var(--chat-gradient);
    color: white;
    border-top-left-radius: 18px;
    border-top-right-radius: 4px;
    margin-left: 0;
    margin-right: 38px;
}

.chat-message.user .chat-message-bubble::before {
    left: auto;
    right: -8px;
    border-width: 0 0 8px 8px;
    border-color: transparent transparent transparent var(--chat-primary);
}

.chat-message.user .chat-message-header {
    flex-direction: row-reverse;
}

.chat-message.user .chat-message-name {
    text-align: right;
}

.chat-system-message {
    text-align: center;
    font-size: 11px;
    color: var(--chat-text-secondary);
    padding: 10px 15px;
    margin: 10px 0;
    background: rgba(255, 77, 77, 0.1);
    border-radius: 20px;
    display: inline-block;
    align-self: center;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 77, 77, 0.2);
}

.chat-system-message i {
    margin-right: 6px;
    color: var(--chat-primary);
}

/* ========== CHAT INPUT AREA ========== */
.chat-widget-input {
    padding: 18px 20px;
    background: var(--chat-bg-dark);
    border-top: 1px solid var(--chat-border);
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
    background: var(--chat-bg-input);
    border-radius: 25px;
    padding: 5px;
    border: 1px solid var(--chat-border);
    transition: all 0.3s;
}

.chat-input-wrapper:focus-within {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(255, 77, 77, 0.2);
}

.chat-input-field {
    flex: 1;
    background: transparent;
    border: none;
    padding: 10px 15px;
    font-size: 13px;
    color: var(--chat-text-primary);
    outline: none;
}

.chat-input-field::placeholder {
    color: var(--chat-text-secondary);
    font-style: italic;
}

.chat-emoji-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.3s;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--chat-text-secondary);
}

.chat-emoji-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    color: var(--chat-primary);
    transform: scale(1.1);
}

.chat-send-btn {
    background: var(--chat-gradient);
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(255, 77, 77, 0.3);
}

.chat-send-btn:hover {
    transform: scale(1.1) rotate(10deg);
    box-shadow: 0 6px 16px rgba(255, 77, 77, 0.5);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.chat-send-btn i {
    font-size: 18px;
}

/* ========== TYPING INDICATOR ========== */
.chat-typing-indicator {
    display: none;
    padding: 12px 20px;
    font-size: 12px;
    color: var(--chat-text-secondary);
    font-style: italic;
    background: var(--chat-bg-card);
    margin: 5px 15px;
    border-radius: 20px;
    align-self: flex-start;
}

.chat-typing-indicator.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.chat-typing-dots {
    display: inline-block;
    margin-left: 5px;
}

.chat-typing-dots span {
    animation: typingDot 1.4s infinite;
    font-size: 16px;
    line-height: 1;
}

.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% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

/* ========== TOAST NOTIFICATION ========== */
.chat-toast-notification {
    position: fixed;
    bottom: 100px;
    right: 25px;
    background: var(--chat-bg-card);
    padding: 16px 20px;
    border-radius: 16px;
    box-shadow: var(--chat-shadow);
    display: none;
    max-width: 320px;
    z-index: 999998;
    animation: toastSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--chat-primary);
    backdrop-filter: blur(10px);
}

.chat-toast-notification.active {
    display: block;
}

@keyframes toastSlide {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.chat-toast-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.chat-toast-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--chat-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    font-weight: 700;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.chat-toast-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--chat-text-primary);
}

.chat-toast-message {
    font-size: 12px;
    color: var(--chat-text-secondary);
    margin-left: 48px;
    line-height: 1.5;
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== RESPONSIVE DESIGN ========== */
@media (max-width: 768px) {
    .chat-widget-container {
        bottom: 15px;
        right: 15px;
    }
    
    .chat-widget-button {
        width: 55px;
        height: 55px;
    }
    
    .chat-widget-button i {
        font-size: 26px;
    }
    
    .chat-widget-box {
        width: calc(100vw - 30px);
        height: 500px;
        bottom: 75px;
    }
}

@media (max-width: 480px) {
    .chat-widget-container {
        bottom: 10px;
        right: 10px;
    }
    
    .chat-widget-box {
        width: calc(100vw - 20px);
        height: 450px;
        bottom: 70px;
    }
    
    .chat-widget-header {
        padding: 15px;
    }
    
    .chat-header-avatar {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .chat-header-text h5 {
        font-size: 14px;
    }
    
    .chat-widget-messages {
        padding: 15px;
    }
    
    .chat-message-bubble {
        padding: 10px 14px;
        font-size: 12px;
    }
}

/* ========== DARK MODE ENHANCEMENTS ========== */
@media (prefers-color-scheme: dark) {
    .chat-widget-box {
        background: var(--chat-bg-dark);
    }
}

/* ========== UTILITY CLASSES ========== */
.chat-hidden {
    display: none !important;
}

.chat-text-glow {
    text-shadow: 0 0 10px rgba(255, 77, 77, 0.5);
}

.chat-border-glow {
    box-shadow: 0 0 15px rgba(255, 77, 77, 0.3);
}