/**
 * Saaqi AI Chat Widget Styles
 * Responsive, animated floating chat widget with Saaqi Tech branding
 * Fixed text visibility issues with explicit color declarations
 */

:root {
    /* Saaqi Tech Brand Colors */
    --saqi-primary-color: #e63946;
    --saqi-primary-hover: #f04252;
    --saqi-dark-slate: #0d0f12;
    --saqi-dark-slate-light: #1a1d21;
    
    /* High Contrast Colors */
    --saqi-text-color: #0f172a;
    --saqi-text-light: #64748b;
    --saqi-text-white: #ffffff;
    --saqi-border-color: #e2e8f0;
    --saqi-success-color: #10b981;
    
    /* Background Colors */
    --saqi-bg-white: #ffffff;
    --saqi-bg-light: #f1f5f9;
    --saqi-bg-dark: #1a1a1a;
    
    /* UI Properties */
    --saqi-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --saqi-border-radius: 16px;
    --saqi-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Main Widget Container */
.saqi-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Floating Launcher Button */
.saqi-chat-launcher {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--saqi-primary-color), var(--saqi-primary-hover));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(230, 57, 70, 0.4);
    transition: var(--saqi-transition);
    z-index: 100000;
}

.saqi-chat-launcher:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(230, 57, 70, 0.5);
}

.saqi-chat-launcher:active {
    transform: scale(0.95);
}

.saqi-chat-launcher .saqi-chat-icon {
    width: 28px;
    height: 28px;
    color: var(--saqi-text-white);
    transition: var(--saqi-transition);
}

.saqi-chat-launcher.active .saqi-chat-icon {
    opacity: 0;
    transform: scale(0);
}

.saqi-chat-launcher.active::after {
    content: '×';
    position: absolute;
    color: var(--saqi-text-white);
    font-size: 32px;
    font-weight: 300;
    opacity: 1;
    transform: scale(1);
}

/* Notification Badge */
.saqi-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: var(--saqi-success-color);
    border: 2px solid var(--saqi-text-white);
    border-radius: 50%;
    display: none;
    animation: pulse 2s infinite;
}

.saqi-chat-badge.visible {
    display: block;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

/* Chat Window */
.saqi-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-height: 580px;
    background: #ffffff !important;
    border-radius: var(--saqi-border-radius);
    box-shadow: var(--saqi-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    pointer-events: none;
    transition: var(--saqi-transition);
    border: 1px solid var(--saqi-border-color) !important;
}

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

/* Chat Header */
.saqi-chat-header {
    background: linear-gradient(135deg, var(--saqi-dark-slate), var(--saqi-dark-slate-light));
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--saqi-text-white);
    border-bottom: 2px solid var(--saqi-primary-color);
}

.saqi-chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.saqi-chat-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    overflow: hidden;
}

.saqi-chat-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 4px;
}

.saqi-chat-header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--saqi-text-white);
}

.saqi-chat-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--saqi-text-white);
}

.saqi-chat-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--saqi-success-color);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.saqi-chat-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--saqi-transition);
    color: var(--saqi-text-white);
}

.saqi-chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.saqi-chat-close-btn i {
    font-size: 18px;
    color: var(--saqi-text-white);
}

.saqi-chat-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.saqi-chat-clear-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--saqi-transition);
    color: var(--saqi-text-white);
}

.saqi-chat-clear-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.saqi-chat-clear-btn i {
    font-size: 16px;
    color: var(--saqi-text-white);
}

/* Chat Messages Container */
.saqi-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f1f5f9 !important;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

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

.saqi-chat-messages::-webkit-scrollbar-thumb {
    background: var(--saqi-border-color);
    border-radius: 3px;
}

.saqi-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--saqi-text-light);
}

/* Message Bubbles */
.saqi-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    animation: messageSlide 0.3s ease-out;
    word-wrap: break-word;
}

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

.saqi-message.bot {
    background: #f1f5f9 !important;
    color: #0f172a !important;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.saqi-message.bot *,
.saqi-message.bot .message-content,
.saqi-message.bot .message-time {
    color: #0f172a !important;
}

.saqi-message.user {
    background: #2563eb !important;
    color: #ffffff !important;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.saqi-message.user *,
.saqi-message.user .message-content,
.saqi-message.user .message-time {
    color: #ffffff !important;
}

.saqi-message .message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 6px;
    display: block;
}

/* Typing Indicator */
.saqi-chat-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #ffffff !important;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    width: fit-content;
}

.saqi-chat-typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--saqi-text-light);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.saqi-chat-typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.saqi-chat-typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Chat Input Container */
.saqi-chat-input-container {
    padding: 16px 20px;
    background: #ffffff !important;
    border-top: 1px solid var(--saqi-border-color) !important;
}

.saqi-chat-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.saqi-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--saqi-border-color) !important;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: var(--saqi-transition);
    background: #ffffff !important;
    color: #0f172a !important;
}

.saqi-chat-input:focus {
    border-color: var(--saqi-primary-color) !important;
    background: #ffffff !important;
}

.saqi-chat-input::placeholder {
    color: #64748b !important;
    opacity: 1 !important;
}

.saqi-chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--saqi-primary-color), var(--saqi-primary-hover));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--saqi-transition);
    flex-shrink: 0;
}

.saqi-chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(230, 57, 70, 0.4);
}

.saqi-chat-send-btn:active {
    transform: scale(0.95);
}

.saqi-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.saqi-chat-send-btn i {
    font-size: 20px;
    color: var(--saqi-text-white);
}

/* Responsive Design */
@media (max-width: 480px) {
    .saqi-chat-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
    
    .saqi-chat-launcher {
        width: 56px;
        height: 56px;
    }
    
    .saqi-chat-window {
        width: 100%;
        height: calc(100vh - 80px);
        max-height: 600px;
        bottom: 76px;
        right: 0;
        left: 0;
        border-radius: 16px 16px 0 0;
    }
    
    .saqi-chat-messages {
        padding: 16px;
    }
    
    .saqi-message {
        max-width: 90%;
    }
}

/* Welcome Tooltip Animation */
@keyframes tooltipBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

.saqi-welcome-tooltip {
    position: absolute;
    bottom: 90px;
    right: 70px;
    background: var(--saqi-dark-slate);
    color: var(--saqi-text-white);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13px;
    white-space: nowrap;
    animation: tooltipBounce 2s infinite;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.saqi-welcome-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 20px;
    width: 12px;
    height: 12px;
    background: var(--saqi-dark-slate);
    transform: rotate(45deg);
}
