/**
 * 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-badge {
    display: none;
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: #ffffff;
    border: 2px solid #ffffff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    animation: badgePulse 1.5s infinite;
}

.saqi-chat-badge.has-unread {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

@keyframes badgePulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.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: 425px;
    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: translateY(20px);
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--saqi-border-color) !important;
}

.saqi-chat-window.open {
    opacity: 1;
    transform: 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);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.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) !important;
}

.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;
    min-height: 0;
    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.admin-reply {
    background: #eff6ff !important;
    border: 1px solid #bfdbfe !important;
    border-left: 4px solid #2563eb !important;
}

.saqi-admin-badge {
    font-size: 11px;
    font-weight: 600;
    color: #1e40af !important;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
}

.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;
        overflow-y: auto;
    padding-top: 0px;

}

.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: #111 !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);
}

body.body-blue * {
    color: #000000 !important;
}

/* Authentication Form Container */
.saqi-auth-form-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    background: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 100%) !important;
    animation: fadeIn 0.3s ease;
    color: #000000 !important;
    box-sizing: border-box;
}

.saqi-auth-form-container::-webkit-scrollbar {
    width: 6px;
}

.saqi-auth-form-container::-webkit-scrollbar-track {
    background: transparent;
}

.saqi-auth-form-container::-webkit-scrollbar-thumb {
    background: var(--saqi-border-color);
    border-radius: 3px;
}

.saqi-auth-form-container::-webkit-scrollbar-thumb:hover {
    background: var(--saqi-text-light);
}

/* Enforce dark/black text colors inside light form container */
.saqi-auth-form-container *,
.saqi-auth-content *,
#saqi-auth-form *,
#saqi-user-form * {
    color: #000000 !important;
}

.saqi-auth-content {
    width: 100%;
    max-width: 360px;
    text-align: center;
    background: #ffffff !important;
    padding: 28px 24px 24px;
    border-radius: 16px;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04) !important;
    box-sizing: border-box;
    margin: 0 auto;
}

.saqi-auth-title {
    font-size: 19px;
    font-weight: 700;
    color: #0f172a !important;
    margin: 0 0 8px;
    letter-spacing: -0.4px;
}

.saqi-auth-subtitle {
    font-size: 13px;
    font-weight: 400;
    color: #64748b !important;
    margin: 0 0 22px;
    line-height: 1.55;
}

/* User Details Form */
.saqi-user-details-form {
    text-align: left;
    width: 100%;
    box-sizing: border-box;
}

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

.saqi-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151 !important;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Input Wrapper & Icon */
.saqi-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.saqi-input-icon {
    position: absolute;
    left: 14px;
    font-size: 18px;
    color: #475569 !important;
    pointer-events: none;
    transition: var(--saqi-transition);
    z-index: 2;
}

.saqi-form-input {
    width: 100%;
    padding: 11px 14px 11px 42px !important;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 400;
    outline: none;
    transition: var(--saqi-transition);
    background: #f8fafc !important;
    color: #0f172a !important;
    box-sizing: border-box;
    box-shadow: none !important;
}

.saqi-form-input:focus {
    color: #0f172a !important;
    border-color: var(--saqi-primary-color) !important;
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.1) !important;
    background: #ffffff !important;
}

.saqi-input-wrapper:focus-within .saqi-input-icon {
    color: var(--saqi-primary-color) !important;
}

.saqi-form-input::placeholder {
    color: #475569 !important;
    opacity: 0.9 !important;
    font-weight: 400;
}

.saqi-auth-submit-btn {
    width: 100%;
    padding: 13px 24px;
    background: linear-gradient(135deg, #e63946 0%, #c1121f 100%) !important;
    border: none;
    border-radius: 12px;
    color: #ffffff !important;
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--saqi-transition);
    margin-top: 20px;
    box-shadow: 0 4px 14px rgba(230, 57, 70, 0.4), 0 1px 3px rgba(0,0,0,0.1) !important;
    position: relative;
    overflow: hidden;
}

.saqi-auth-submit-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 60%);
    border-radius: inherit;
    pointer-events: none;
}

.saqi-auth-submit-btn span,
.saqi-auth-submit-btn i {
    color: #ffffff !important;
    position: relative;
    z-index: 1;
}

.saqi-auth-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(230, 57, 70, 0.5), 0 2px 6px rgba(0,0,0,0.12) !important;
}

.saqi-auth-submit-btn:active {
    transform: translateY(0px);
    box-shadow: 0 2px 8px rgba(230, 57, 70, 0.3) !important;
}

.saqi-auth-submit-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none !important;
}

.saqi-form-note {
    font-size: 11.5px;
    font-weight: 400;
    color: #94a3b8 !important;
    text-align: center;
    margin: 16px 0 0;
}

/* Success Animation Container */
.saqi-success-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    background: linear-gradient(145deg, #f0fdf4 0%, #dcfce7 100%) !important;
    border-radius: var(--saqi-border-radius);
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
    box-sizing: border-box;
}

.saqi-success-icon {
    width: 76px;
    height: 76px;
    background: linear-gradient(135deg, #059669, #047857) !important;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
    animation: successPulse 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 6px 20px rgba(5, 150, 105, 0.35) !important;
}

.saqi-success-icon i {
    font-size: 38px;
    color: #ffffff !important;
    animation: checkmarkDraw 0.4s ease-out 0.2s both;
}

.saqi-success-text {
    font-size: 19px;
    font-weight: 700;
    color: #022c22 !important; /* Dark legible green text */
    margin: 0;
    text-align: center;
    animation: slideUp 0.4s ease-out 0.3s both;
    letter-spacing: -0.2px;
}

@keyframes successPulse {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes checkmarkDraw {
    0% {
        transform: scale(0) rotate(-45deg);
        opacity: 0;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes slideUp {
    0% {
        transform: translateY(20px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Form validation states */
.saqi-form-input:invalid:not(:placeholder-shown) {
    border-color: #ef4444 !important;
}

.saqi-form-input:invalid:not(:placeholder-shown):focus {
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15) !important;
}