/* ===================================
   Chat Widget Styles - macOS Style
   =================================== */

/* Body scroll lock when chat is open */
body.chat-open {
    overflow: hidden !important;
}

/* Chat Button (Floating) - Using CSS Variables */
.chat-button {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary, #17c3b2), var(--secondary, #06b6d4));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(23, 195, 178, 0.4);
    z-index: 9998;
    transition: all 0.3s ease;
    border: none;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(23, 195, 178, 0.6);
}

.chat-button .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

/* Chat Window - macOS style */
.chat-window {
    position: fixed;
    bottom: 100px;
    left: 30px;
    width: 380px;
    height: 600px;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    box-shadow: 0 22px 70px 4px rgba(0,0,0,0.18), 0 0 0 0.5px rgba(0,0,0,0.08);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    direction: rtl;
    /* Smooth transition for maximize/minimize */
    transition: top 0.4s cubic-bezier(0.22, 1, 0.36, 1),
                left 0.4s cubic-bezier(0.22, 1, 0.36, 1),
                right 0.4s cubic-bezier(0.22, 1, 0.36, 1),
                bottom 0.4s cubic-bezier(0.22, 1, 0.36, 1),
                width 0.4s cubic-bezier(0.22, 1, 0.36, 1),
                height 0.4s cubic-bezier(0.22, 1, 0.36, 1),
                border-radius 0.4s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.4s cubic-bezier(0.22, 1, 0.36, 1),
                margin 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-window.active {
    display: flex;
    animation: macFadeIn 0.35s ease;
}

.chat-window.closing {
    animation: macFadeOut 0.25s ease forwards;
}

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

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

/* Chat Header - macOS Titlebar (Frosted Glass) */
.chat-header {
    background: rgba(255,255,255,0.35);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid rgba(255,255,255,0.3);
    color: #333;
    padding: 0 1rem;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    -webkit-app-region: drag;
}

[data-theme="dark"] .chat-header {
    background: rgba(30,30,32,0.4);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    color: #f5f5f7;
}

.chat-header-info {
    flex: 1;
    text-align: center;
    pointer-events: none;
}

.chat-header h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    color: #333;
}

[data-theme="dark"] .chat-header h3 {
    color: #f5f5f7;
}

.chat-header h3 i {
    color: var(--primary, #17c3b2);
}

.chat-header .status {
    font-size: 0.7rem;
    color: #86868b;
    margin-top: 0.1rem;
    text-align: center;
}

/* macOS Traffic Light Buttons */
.chat-traffic-lights {
    display: flex;
    align-items: center;
    gap: 8px;
    -webkit-app-region: no-drag;
    padding: 0 4px;
}

.chat-traffic-lights .tl-btn {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    position: relative;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.chat-traffic-lights .tl-btn i {
    font-size: 7px;
    opacity: 0;
    transition: opacity 0.15s;
    color: rgba(0,0,0,0.5);
    line-height: 1;
}

.chat-traffic-lights:hover .tl-btn i {
    opacity: 1;
}

.tl-close {
    background: #ff5f57;
    box-shadow: 0 0 0 0.5px rgba(0,0,0,0.12);
}
.tl-close:hover {
    background: #ff3b30;
}

.tl-minimize {
    background: #ffbd2e;
    box-shadow: 0 0 0 0.5px rgba(0,0,0,0.12);
}
.tl-minimize:hover {
    background: #ff9f0a;
}

.tl-maximize {
    background: #28c840;
    box-shadow: 0 0 0 0.5px rgba(0,0,0,0.12);
}
.tl-maximize:hover {
    background: #32d74b;
}

/* Inactive state */
.chat-window:not(:hover) .chat-traffic-lights .tl-btn {
    /* Show dots even when not hovering the titlebar */
}

[data-theme="dark"] .tl-close { background: #ff453a; }
[data-theme="dark"] .tl-minimize { background: #ff9f0a; }
[data-theme="dark"] .tl-maximize { background: #30d158; }

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    background: rgba(249, 250, 251, 0.65);
}

[data-theme="dark"] .chat-messages {
    background: rgba(28, 28, 30, 0.6);
}

[data-theme="dark"] .chat-window {
    background: rgba(44, 44, 46, 0.75);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 22px 70px 4px rgba(0,0,0,0.5), 0 0 0 0.5px rgba(255,255,255,0.08);
}

[data-theme="dark"] .chat-input-area {
    background: #2c2c2e;
    border-top-color: #3a3a3c;
}

[data-theme="dark"] .chat-input {
    background: #1c1c1e;
    color: #f5f5f7;
    border-color: #3a3a3c;
}

[data-theme="dark"] .message-bubble.admin {
    background: #3a3a3c;
    color: #f5f5f7;
    border-color: #48484a;
}

.chat-message {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

.chat-message.user {
    align-items: flex-end;
}

.chat-message.admin {
    align-items: flex-start;
}

.message-bubble {
    max-width: 75%;
    padding: 0.75rem 1rem;
    border-radius: 18px;
    word-wrap: break-word;
    position: relative;
}

.message-bubble.user {
    background: linear-gradient(135deg, var(--primary, #17c3b2), var(--secondary, #06b6d4));
    color: white;
    border-bottom-right-radius: 4px;
}

.message-bubble.admin {
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 0.7rem;
    color: #6b7280;
    margin-top: 0.25rem;
    padding: 0 0.5rem;
}

.message-status {
    font-size: 0.65rem;
    color: #9ca3af;
    margin-top: 0.15rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Chat Input */
.chat-input-area {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.7);
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    position: relative;
}

/* Suggestions + Button */
.chat-suggestions-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: #f3f4f6;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.25s ease;
}

.chat-suggestions-btn:hover {
    background: var(--primary, #17c3b2);
    border-color: var(--primary, #17c3b2);
    color: #fff;
}

.chat-suggestions-btn.active {
    background: var(--primary, #17c3b2);
    border-color: var(--primary, #17c3b2);
    color: #fff;
    transform: rotate(45deg);
}

.chat-suggestions-popup {
    display: none;
    position: absolute;
    bottom: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 1rem;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    z-index: 10;
    animation: suggestionsSlideUp 0.2s ease;
}

.chat-suggestions-popup.active {
    display: block;
}

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

.chat-suggestions-popup .suggestions-title {
    font-size: 0.8rem;
    color: #6b7280;
    font-weight: 600;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.chat-suggestions-popup .suggestions-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.chat-suggestions-popup .suggestion-chip {
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    color: #374151;
    padding: 0.45rem 0.85rem;
    border-radius: 20px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.chat-suggestions-popup .suggestion-chip:hover {
    border-color: var(--primary, #17c3b2);
    color: var(--primary, #17c3b2);
    background: rgba(23, 195, 178, 0.06);
}

.chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 25px;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s;
    direction: rtl;
}

.chat-input:focus {
    border-color: var(--primary, #17c3b2);
}

.chat-send-btn {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, var(--primary, #17c3b2), var(--secondary, #06b6d4));
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-send-btn:hover {
    transform: scale(1.05);
}

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

/* Empty State */
.chat-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

.chat-empty i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 18px;
    max-width: 75px;
    margin-bottom: 1rem;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Maximized Chat State - macOS centered */
.chat-window.maximized {
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    margin: auto;
    width: min(680px, 90vw);
    height: min(780px, 85vh);
    border-radius: 12px;
    box-shadow: 0 30px 90px rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.05);
}

/* Overlay when maximized */
.chat-maximize-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.15);
    z-index: 9998;
    display: none;
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
}

.chat-maximize-overlay.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

[data-theme="dark"] .chat-maximize-overlay {
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(14px) saturate(150%) brightness(0.7);
    -webkit-backdrop-filter: blur(14px) saturate(150%) brightness(0.7);
}

.chat-maximize-overlay.hiding {
    animation: fadeOut 0.3s ease forwards;
}

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

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

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

    .chat-window.active {
        animation: none;
    }

    .chat-window.maximized {
        width: 100%;
        height: 100%;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        margin: 0;
        border-radius: 0;
    }
    
    .chat-button {
        bottom: 80px;
        left: 20px;
        width: 55px;
        height: 55px;
    }

    .chat-input {
        font-size: 16px;
    }

    .tl-maximize {
        display: none;
    }
}
