/* ============================================
   ResaDZ Chatbot - Résabot Styles
   All classes prefixed with .resabot- to avoid conflicts
   ============================================ */

/* --- Animations --- */
@keyframes resabot-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 44, 0.5); }
    50% { box-shadow: 0 0 0 12px rgba(255, 107, 44, 0); }
}

@keyframes resabot-slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes resabot-slideDown {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
}

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

@keyframes resabot-badgePop {
    0% { transform: scale(0); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* --- Floating Button --- */
.resabot-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF6B2C, #F59E0B);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    box-shadow: 0 4px 20px rgba(255, 107, 44, 0.35);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.resabot-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(255, 107, 44, 0.45);
}

.resabot-fab.resabot-fab--idle {
    animation: resabot-pulse 2.5s ease-in-out infinite;
}

.resabot-fab svg {
    width: 28px;
    height: 28px;
    fill: #ffffff;
    transition: transform 0.3s ease;
}

.resabot-fab.resabot-fab--open svg.resabot-icon-chat {
    display: none;
}

.resabot-fab.resabot-fab--open svg.resabot-icon-close {
    display: block;
}

.resabot-fab:not(.resabot-fab--open) svg.resabot-icon-chat {
    display: block;
}

.resabot-fab:not(.resabot-fab--open) svg.resabot-icon-close {
    display: none;
}

/* --- Badge --- */
.resabot-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #EF4444;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid #ffffff;
    line-height: 1;
    animation: resabot-badgePop 0.3s ease;
}

.resabot-badge.resabot-badge--visible {
    display: flex;
}

/* --- Chat Window --- */
.resabot-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 360px;
    height: 500px;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    transform-origin: bottom right;
}

.resabot-window.resabot-window--opening {
    animation: resabot-slideUp 0.3s ease forwards;
}

.resabot-window.resabot-window--closing {
    animation: resabot-slideDown 0.25s ease forwards;
}

.resabot-window.resabot-window--hidden {
    display: none;
}

/* --- Header --- */
.resabot-header {
    background: linear-gradient(135deg, #FF6B2C, #F59E0B);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.resabot-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

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

.resabot-header-name {
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
}

.resabot-header-status {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 5px;
}

.resabot-header-status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ADE80;
    display: inline-block;
    flex-shrink: 0;
}

.resabot-header-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

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

.resabot-header-close svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
}

/* --- Messages Zone --- */
.resabot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background: #FAFAFA;
}

.resabot-messages::-webkit-scrollbar {
    width: 4px;
}

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

.resabot-messages::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 2px;
}

/* --- Message Bubbles --- */
.resabot-msg {
    max-width: 85%;
    animation: resabot-fadeIn 0.35s ease;
}

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

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

.resabot-msg-bubble {
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-line;
}

.resabot-msg--bot .resabot-msg-bubble {
    background: #F1F5F9;
    color: #1E293B;
    border-radius: 16px;
    border-top-left-radius: 4px;
}

.resabot-msg--user .resabot-msg-bubble {
    background: linear-gradient(135deg, #FF6B2C, #F59E0B);
    color: #ffffff;
    border-radius: 16px;
    border-top-right-radius: 4px;
}

.resabot-msg-time {
    font-size: 11px;
    color: #9CA3AF;
    margin-top: 4px;
    padding: 0 4px;
}

.resabot-msg--bot .resabot-msg-time {
    text-align: left;
}

.resabot-msg--user .resabot-msg-time {
    text-align: right;
}

/* --- Quick Reply Pills --- */
.resabot-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0 0 0;
    animation: resabot-fadeIn 0.4s ease;
}

.resabot-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 7px 14px;
    border: 1.5px solid #FF6B2C;
    border-radius: 20px;
    background: #ffffff;
    color: #FF6B2C;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.resabot-pill:hover {
    background: #FF6B2C;
    color: #ffffff;
}

/* --- Link Button --- */
.resabot-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 10px;
    background: linear-gradient(135deg, #FF6B2C, #F59E0B);
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    margin-top: 6px;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.resabot-link-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.resabot-link-btn svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
}

/* --- Inline Link in bot message --- */
.resabot-inline-link {
    color: #FF6B2C;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-style: dashed;
    text-underline-offset: 2px;
}
.resabot-inline-link:hover {
    text-decoration-style: solid;
    color: #EA580C;
}

/* --- Typing Indicator --- */
.resabot-typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
    background: #F1F5F9;
    border-radius: 16px;
    border-top-left-radius: 4px;
    animation: resabot-fadeIn 0.3s ease;
}

.resabot-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94A3B8;
    animation: resabot-typingBounce 1.4s ease-in-out infinite;
}

.resabot-typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.resabot-typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes resabot-typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* --- Input Area --- */
.resabot-input-area {
    padding: 12px 14px;
    border-top: 1px solid #F1F5F9;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    background: #ffffff;
}

.resabot-input {
    flex: 1;
    border: 1.5px solid #E5E7EB;
    border-radius: 24px;
    padding: 9px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
    background: #F9FAFB;
    color: #1E293B;
    font-family: inherit;
}

.resabot-input::placeholder {
    color: #9CA3AF;
}

.resabot-input:focus {
    border-color: #FF6B2C;
    background: #ffffff;
}

/* --- Mic Button --- */
.resabot-mic-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #F1F5F9;
    color: #64748B;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.resabot-mic-btn:hover {
    background: #E2E8F0;
    color: #FF6B2C;
}

.resabot-mic-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    stroke: none;
}

.resabot-mic-btn svg path[fill="none"] {
    fill: none;
    stroke: currentColor;
}

.resabot-mic-btn svg line {
    stroke: currentColor;
}

.resabot-mic-btn--active {
    background: #EF4444;
    color: #ffffff;
    animation: resabot-micPulse 1.5s ease-in-out infinite;
}

.resabot-mic-btn--active:hover {
    background: #DC2626;
    color: #ffffff;
}

@keyframes resabot-micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

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

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

.resabot-send-btn:disabled {
    opacity: 0.5;
    cursor: default;
    transform: none;
}

.resabot-send-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- Responsive: Mobile full-width --- */
@media (max-width: 480px) {
    .resabot-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .resabot-fab {
        bottom: 16px;
        right: 16px;
    }

    .resabot-window.resabot-window--opening {
        animation: resabot-slideUpMobile 0.3s ease forwards;
    }

    .resabot-window.resabot-window--closing {
        animation: resabot-slideDownMobile 0.25s ease forwards;
    }
}

@keyframes resabot-slideUpMobile {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes resabot-slideDownMobile {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(100%);
    }
}
