/**
 * ZAYNAH AI Chat Widget Styles
 *
 * Light WhatsApp-style theme with gradient accents
 *
 * @package ZAYNAH_AI
 */

/* CSS Custom Properties - WhatsApp Light Theme */
:root {
    /* Light theme colors */
    --zaynah-bg: #ffffff;
    --zaynah-header: linear-gradient(135deg, #f43f5e, #ec4899);
    --zaynah-text: #111b21;
    --zaynah-text-light: #667781;
    --zaynah-user-bubble: #d9fdd3;
    --zaynah-bot-bubble: #ffffff;
    --zaynah-input-bg: #f0f2f5;
    --zaynah-border: #e9edef;
    --zaynah-border-radius: 12px;
    --zaynah-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --zaynah-trigger-shadow: 0 2px 12px rgba(37, 211, 102, 0.4);
    /* Chat background pattern like WhatsApp */
    --zaynah-chat-bg: #efeae2;
}

/* Trigger Button - WhatsApp Green */
.zaynah-trigger {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #f43f5e, #ec4899);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--zaynah-trigger-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: none;
    padding: 0;
}

.zaynah-trigger:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.5);
}

.zaynah-trigger:focus {
    outline: 2px solid #f43f5e;
    outline-offset: 2px;
}

.zaynah-trigger.zaynah-left {
    right: auto;
    left: 20px;
}

.zaynah-logo {
    width: 28px;
    height: 28px;
}

/* Override logo color for light trigger */
.zaynah-trigger .zaynah-logo path {
    stroke: white !important;
}

/* Chat Window - Compact Size */
.zaynah-chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 340px;
    height: 450px;
    background: var(--zaynah-bg);
    border-radius: 16px;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    display: none;
    flex-direction: column;
    z-index: 99999;
    overflow: hidden;
    font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, 'Lucida Grande', Arial, sans-serif;
    border: 1px solid var(--zaynah-border);
}

.zaynah-chat-window.zaynah-left {
    right: auto;
    left: 20px;
}

.zaynah-chat-window.open {
    display: flex;
    animation: zaynah-slide-up 0.25s ease-out;
}

@keyframes zaynah-slide-up {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header - WhatsApp Green */
.zaynah-header {
    background: var(--zaynah-header);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.zaynah-header-info {
    display: flex;
    flex-direction: column;
}

.zaynah-title {
    font-weight: 600;
    font-size: 16px;
    color: #ffffff;
    letter-spacing: 0.2px;
}

.zaynah-subtitle {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 1px;
}

.zaynah-close {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.zaynah-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.zaynah-close:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Messages Container - WhatsApp Chat BG */
.zaynah-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-color: var(--zaynah-chat-bg);
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d4cfc6' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.zaynah-messages::-webkit-scrollbar {
    width: 5px;
}

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

.zaynah-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

.zaynah-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* Message Bubbles - WhatsApp Style */
.zaynah-message {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 8px;
    animation: zaynah-msg-in 0.2s ease;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
    position: relative;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

@keyframes zaynah-msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.zaynah-message.user {
    background: var(--zaynah-user-bubble);
    color: var(--zaynah-text);
    margin-left: auto;
    border-top-right-radius: 2px;
}

.zaynah-message.bot {
    background: var(--zaynah-bot-bubble);
    color: var(--zaynah-text);
    margin-right: auto;
    border-top-left-radius: 2px;
}

/* Typing Indicator */
.zaynah-typing {
    display: flex;
    gap: 3px;
    padding: 10px 14px;
}

.zaynah-typing span {
    width: 7px;
    height: 7px;
    background: var(--zaynah-text-light);
    border-radius: 50%;
    animation: zaynah-typing-dot 1.4s infinite ease-in-out;
}

.zaynah-typing span:nth-child(1) {
    animation-delay: 0s;
}

.zaynah-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.zaynah-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes zaynah-typing-dot {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Area */
.zaynah-input-area {
    padding: 10px 12px;
    display: flex;
    gap: 8px;
    background: var(--zaynah-input-bg);
    flex-shrink: 0;
}

.zaynah-input {
    flex: 1;
    background: #ffffff;
    border: 1px solid var(--zaynah-border);
    border-radius: 20px;
    padding: 10px 16px;
    color: var(--zaynah-text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.zaynah-input::placeholder {
    color: var(--zaynah-text-light);
}

.zaynah-input:focus {
    border-color: #f43f5e;
}

.zaynah-send-btn {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #f43f5e, #ec4899);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, opacity 0.15s ease;
    flex-shrink: 0;
}

.zaynah-send-btn:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.zaynah-send-btn:focus {
    outline: 2px solid #f43f5e;
    outline-offset: 2px;
}

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

.zaynah-send-btn svg {
    width: 18px;
    height: 18px;
}

/* Error Message Styling */
.zaynah-message.error {
    background: #ffebee;
    color: #c62828;
    border-left: 3px solid #c62828;
}

/* Success Message Styling */
.zaynah-message.success {
    background: #e8f5e9;
    color: #2e7d32;
    border-left: 3px solid #2e7d32;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .zaynah-chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        max-height: 100vh;
        max-height: 100dvh;
    }

    .zaynah-chat-window.zaynah-left {
        left: 0;
        right: 0;
    }

    .zaynah-trigger {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }

    .zaynah-trigger.zaynah-left {
        right: auto;
        left: 16px;
    }

    .zaynah-logo {
        width: 26px;
        height: 26px;
    }

    .zaynah-header {
        padding: 16px;
    }

    .zaynah-messages {
        padding: 10px;
    }

    .zaynah-message {
        max-width: 88%;
    }

    .zaynah-input-area {
        padding: 10px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
}

/* Print Styles - Hide Widget */
@media print {
    .zaynah-trigger,
    .zaynah-chat-window {
        display: none !important;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .zaynah-trigger,
    .zaynah-chat-window,
    .zaynah-message,
    .zaynah-send-btn {
        animation: none;
        transition: none;
    }

    .zaynah-typing span {
        animation: none;
        opacity: 0.7;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .zaynah-trigger,
    .zaynah-chat-window {
        border: 2px solid #000;
    }

    .zaynah-message.user,
    .zaynah-message.bot {
        border: 1px solid #000;
    }
}
