/* ============================================
   Chat Agent Widget — "Коріння та Крила"
   Matches site brand: #2c3e50, #e67e22, Montserrat
   ============================================ */

/* Toggle Button */
.rw-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(44, 62, 80, 0.4);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: rw-pulse 3s ease-in-out infinite;
}
.rw-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(44, 62, 80, 0.55);
}
.rw-chat-toggle svg {
    width: 26px;
    height: 26px;
    fill: #ffffff;
    transition: transform 0.3s ease;
}
.rw-chat-toggle.active svg {
    transform: rotate(90deg);
}
.rw-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #e67e22;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: rw-badge-pulse 2s ease-in-out infinite;
}
@keyframes rw-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(44, 62, 80, 0.4); }
    50% { box-shadow: 0 4px 20px rgba(230, 126, 34, 0.5); }
}
@keyframes rw-badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Chat Window */
.rw-chat-window {
    position: fixed;
    bottom: 94px;
    right: 24px;
    width: 370px;
    height: 540px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.rw-chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.rw-chat-header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: #ffffff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.rw-chat-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #e67e22, #f39c12);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.rw-chat-header-info {
    flex: 1;
}
.rw-chat-header-title {
    font-family: 'Playfair Display', serif;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}
.rw-chat-header-subtitle {
    font-size: 11px;
    color: #bdc3c7;
    margin-top: 2px;
}
.rw-chat-close {
    background: none;
    border: none;
    color: #bdc3c7;
    cursor: pointer;
    font-size: 20px;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
}
.rw-chat-close:hover {
    color: #ffffff;
}

/* Messages Area */
.rw-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}
.rw-chat-messages::-webkit-scrollbar {
    width: 5px;
}
.rw-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.rw-chat-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

/* Message Bubbles */
.rw-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    font-family: 'Montserrat', sans-serif;
    word-wrap: break-word;
    animation: rw-msg-in 0.3s ease;
}
@keyframes rw-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.rw-msg-bot {
    background: #f0f2f5;
    color: #333;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}
.rw-msg-user {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}
.rw-msg-bot a {
    color: #e67e22;
    text-decoration: underline;
}

/* Typing indicator */
.rw-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #f0f2f5;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: 60px;
}
.rw-typing span {
    width: 7px;
    height: 7px;
    background: #aaa;
    border-radius: 50%;
    animation: rw-typing-dot 1.4s ease-in-out infinite;
}
.rw-typing span:nth-child(2) { animation-delay: 0.2s; }
.rw-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes rw-typing-dot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* Quick Buttons */
.rw-quick-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.rw-quick-btn {
    background: #ffffff;
    border: 1.5px solid #2c3e50;
    color: #2c3e50;
    padding: 6px 13px;
    border-radius: 18px;
    font-size: 12.5px;
    font-family: 'Montserrat', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.rw-quick-btn:hover {
    background: #2c3e50;
    color: #ffffff;
}
.rw-quick-btn.rw-btn-primary {
    background: linear-gradient(135deg, #e67e22, #f39c12);
    border-color: #e67e22;
    color: #ffffff;
    font-weight: 600;
}
.rw-quick-btn.rw-btn-primary:hover {
    background: linear-gradient(135deg, #d35400, #e67e22);
}
.rw-quick-btn.rw-btn-danger {
    border-color: #c0392b;
    color: #c0392b;
}
.rw-quick-btn.rw-btn-danger:hover {
    background: #c0392b;
    color: #ffffff;
}

/* Order Summary */
.rw-order-summary {
    background: #f9f9f9;
    border-radius: 10px;
    padding: 12px;
    margin-top: 6px;
    font-size: 13px;
    border-left: 3px solid #2c3e50;
}
.rw-order-summary .rw-order-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
}
.rw-order-summary .rw-order-label {
    color: #666;
}
.rw-order-summary .rw-order-value {
    color: #2c3e50;
    font-weight: 600;
}
.rw-order-summary .rw-order-total {
    border-top: 1px solid #ddd;
    margin-top: 6px;
    padding-top: 6px;
    font-size: 15px;
}
.rw-order-summary .rw-order-total .rw-order-value {
    color: #e67e22;
    font-weight: 700;
}

/* Input Area */
.rw-chat-input-area {
    padding: 12px 14px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
    background: #fafafa;
}
.rw-chat-input {
    flex: 1;
    border: 1.5px solid #ddd;
    border-radius: 20px;
    padding: 9px 16px;
    font-size: 13.5px;
    font-family: 'Montserrat', sans-serif;
    outline: none;
    resize: none;
    max-height: 80px;
    transition: border-color 0.2s;
    line-height: 1.4;
}
.rw-chat-input:focus {
    border-color: #2c3e50;
}
.rw-chat-input::placeholder {
    color: #aaa;
}
.rw-chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2c3e50, #34495e);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, opacity 0.2s;
}
.rw-chat-send:hover {
    transform: scale(1.08);
}
.rw-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.rw-chat-send svg {
    width: 18px;
    height: 18px;
    fill: #ffffff;
}

/* Mobile */
@media (max-width: 767px) {
    .rw-chat-toggle {
        bottom: 80px;
        right: 16px;
        width: 52px;
        height: 52px;
    }
    .rw-chat-window {
        width: calc(100vw - 16px);
        height: calc(100vh - 160px);
        max-height: calc(100vh - 160px);
        right: 8px;
        bottom: 144px;
        border-radius: 12px;
    }
}
