/**
 * PROWATCH AI Consultant Chat Widget Styles
 * Premium Dark & Matte Gold Aesthetic
 */

/* 1. Floating Round Chat Button */
.pw-chat-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #0e0e0e;
    border: 2px solid #d4af37;
    color: #d4af37;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999990;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 15px rgba(212, 175, 55, 0.25);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.pw-chat-trigger:hover {
    transform: scale(1.08);
    background: #141720;
    border-color: #fce08b;
    color: #fce08b;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.75), 0 0 25px rgba(212, 175, 55, 0.5);
}

.pw-chat-trigger:active {
    transform: scale(0.96);
}

.pw-trigger-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.pw-chat-trigger:hover .pw-trigger-icon {
    transform: rotate(8deg);
}

/* Unread Badge */
.pw-trigger-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: #ef4444;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #0e0e0e;
    animation: pw-pulse-badge 2s infinite;
}

@keyframes pw-pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* 2. Main Chat Window Container */
.pw-chat-box {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: 82vh;
    background: rgba(11, 13, 16, 0.96);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1.5px solid rgba(212, 175, 55, 0.35);
    border-radius: 20px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9), 0 0 35px rgba(212, 175, 55, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 999995;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    font-family: inherit;
}

.pw-chat-box.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* 3. Header */
.pw-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #141720;
    border-bottom: 1px solid rgba(212, 175, 55, 0.25);
}

.pw-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid #d4af37;
    color: #fce08b;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pw-chat-header-info {
    flex: 1;
    min-width: 0;
}

.pw-chat-title {
    color: #fce08b;
    font-size: 0.95rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pw-chat-status {
    color: #94a3b8;
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.pw-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px #22c55e;
}

.pw-chat-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.2s ease;
}

.pw-chat-close:hover {
    color: #fce08b;
}

/* 4. Scrollable Messages Area */
.pw-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

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

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

.pw-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.25);
    border-radius: 10px;
}

/* Message Item Layout */
.pw-msg-row {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    animation: pw-fade-in-msg 0.25s ease-out;
}

@keyframes pw-fade-in-msg {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.pw-msg-row.bot {
    align-self: flex-start;
}

.pw-msg-row.user {
    align-self: flex-end;
}

.pw-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.45;
    word-break: break-word;
}

/* Bot Bubble Styling */
.pw-msg-row.bot .pw-msg-bubble {
    background: #141720;
    color: #f1f5f9;
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-left: 3.5px solid #d4af37;
    border-top-left-radius: 4px;
}

.pw-msg-row.bot .pw-msg-bubble strong {
    color: #fce08b;
}

.pw-msg-row.bot .pw-msg-bubble ul {
    margin: 6px 0 0 16px;
    padding: 0;
}

.pw-msg-row.bot .pw-msg-bubble li {
    margin-bottom: 4px;
}

/* User Bubble Styling */
.pw-msg-row.user .pw-msg-bubble {
    background: linear-gradient(135deg, #d4af37 0%, #aa820a 100%);
    color: #0a0a0a;
    font-weight: 600;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.25);
}

.pw-msg-time {
    font-size: 0.7rem;
    color: #64748b;
    margin-top: 4px;
    align-self: flex-end;
}

.pw-msg-row.user .pw-msg-time {
    color: rgba(212, 175, 55, 0.7);
}

/* 5. Typing Indicator */
.pw-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    margin-bottom: 8px;
}

.pw-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pw-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #d4af37;
    animation: pw-bounce-dot 1.4s infinite ease-in-out both;
}

.pw-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.pw-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes pw-bounce-dot {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.pw-typing-text {
    font-size: 0.76rem;
    color: #d4af37;
    font-style: italic;
}

/* 6. Form & Input Field */
.pw-chat-quick-bar {
    padding: 6px 14px;
    background: #090a0e;
    border-top: 1px solid rgba(212, 175, 55, 0.15);
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
}

.pw-quick-btn {
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid rgba(212, 175, 55, 0.35);
    color: #fce08b;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.pw-quick-btn:hover {
    background: #d4af37;
    color: #0a0a0a;
    border-color: #fce08b;
    transform: translateY(-1px);
}

/* Messenger Interactive Buttons Inside Chat Bubble */
.pw-messenger-btns {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.pw-btn-messenger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.25s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.pw-btn-telegram {
    background: #0088cc;
    color: #ffffff !important;
    border: 1px solid #28a7e9;
}

.pw-btn-telegram:hover {
    background: #0099e6;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 136, 204, 0.5);
}

.pw-btn-viber {
    background: #7360f2;
    color: #ffffff !important;
    border: 1px solid #8f7ffa;
}

.pw-btn-viber:hover {
    background: #8271f8;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(115, 96, 242, 0.5);
}

.pw-chat-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: #06070a;
    border-top: 1px solid rgba(212, 175, 55, 0.25);
}

.pw-chat-input {
    flex: 1;
    background: #141720;
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 10px;
    padding: 10px 14px;
    color: #f8fafc;
    font-size: 0.88rem;
    outline: none;
    transition: all 0.25s ease;
}

.pw-chat-input:focus {
    border-color: #d4af37;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
    background: #1a1e2b;
}

.pw-chat-input::placeholder {
    color: #64748b;
}

.pw-chat-send {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #d4af37;
    border: none;
    color: #0a0a0a;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.pw-chat-send:hover {
    background: #fce08b;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
}

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

/* 7. Mobile Responsive Adaptation */
@media (max-width: 480px) {
    .pw-chat-box {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }

    .pw-chat-trigger {
        bottom: 18px;
        right: 18px;
        width: 54px;
        height: 54px;
    }
}
