/* Danielle Hair Salon - Premium Chatbot Widget Styles */
/* ================================================== */
/* FLOATING UI STACK MANAGER - No Overlap System      */
/* ================================================== */

/*
 * Z-INDEX HIERARCHY (higher = on top):
 * - Chatbot window (open): 2000
 * - Cookie notice: 1500
 * - Chatbot attention bubble: 1101
 * - Chatbot button: 1100
 * - Cherry/Pay widget: 900
 *
 * VERTICAL POSITIONING (bottom-right stack):
 * - Cherry widget: 20px from bottom (lowest)
 * - Chatbot button: 100px from bottom
 * - Chatbot bubble: 180px from bottom (above button)
 * - Cookie notice: bottom-LEFT (separate column)
 */

/* ============================================ */
/* CSS Variables for Floating UI Management    */
/* ============================================ */
:root {
    /* Spacing & Layout */
    --floating-gap: 16px;
    --floating-right: 20px;
    --floating-bottom-safe: max(20px, env(safe-area-inset-bottom));

    /* Element Positions (from bottom) - Cherry is ~50px tall at y:20px offset */
    --cherry-bottom: 20px;
    --chatbot-button-bottom: 140px;
    --chatbot-bubble-bottom: 220px;
    --cookie-bottom: 20px;

    /* Sizes */
    --chatbot-button-size: 64px;
    --chatbot-bubble-max-width: 220px;

    /* Chat Widget Colors */
    --chat-primary: #D4B5A0;
    --chat-primary-dark: #B8957F;
    --chat-secondary: #2C2825;
    --chat-background: #FAF8F5;
    --chat-white: #FFFFFF;
    --chat-gray: #6B6B6B;
    --chat-border: #E0D5CE;
    --chat-shadow: rgba(212, 181, 160, 0.4);
    --chat-shadow-dark: rgba(0, 0, 0, 0.15);
}

/* ============================================ */
/* Floating Chat Button                         */
/* ============================================ */
.chatbot-button {
    position: fixed;
    bottom: 180px !important;
    right: 20px !important;
    width: var(--chatbot-button-size);
    height: var(--chatbot-button-size);
    border-radius: 50%;
    background: linear-gradient(135deg, #8B5A2B 0%, #A0522D 50%, #CD853F 100%);
    border: 3px solid var(--chat-white);
    cursor: pointer;
    box-shadow: 0 6px 25px rgba(139, 90, 43, 0.5);
    z-index: 1100 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* After cookie accepted - move down */
.chatbot-button.cookie-hidden {
    bottom: 80px !important;
}

.chatbot-button::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(139, 90, 43, 0.4);
    animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
    z-index: -1;
}

@keyframes ping {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    75%, 100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.chatbot-button:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 35px rgba(139, 90, 43, 0.6);
}

.chatbot-button:hover::before {
    animation: none;
}

.chatbot-button i {
    font-size: 26px;
    color: var(--chat-white);
    transition: transform 0.3s ease;
    position: relative;
    z-index: 1;
}

.chatbot-button.active i.fa-comments {
    display: none;
}

.chatbot-button.active i.fa-times {
    display: block;
}

.chatbot-button i.fa-times {
    display: none;
}

.chatbot-button.active::before {
    animation: none;
}

/* Pulse Animation - Legacy fallback */
@keyframes chatPulse {
    0%, 100% {
        box-shadow: 0 6px 25px rgba(139, 90, 43, 0.5);
    }
    50% {
        box-shadow: 0 6px 35px rgba(139, 90, 43, 0.7);
    }
}

.chatbot-button.pulse {
    animation: chatPulse 2s ease-in-out;
}

/* ============================================ */
/* Attention Bubble (Speech Tooltip)            */
/* ============================================ */
.chatbot-attention {
    position: fixed;
    bottom: 260px !important;
    right: 20px !important;
    background: var(--chat-white);
    color: #333333;
    padding: 12px 16px;
    border-radius: 16px 16px 4px 16px;
    border: 1px solid var(--chat-border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    z-index: 1101 !important;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), bottom 0.3s ease;
    max-width: var(--chatbot-bubble-max-width);
}

/* After cookie accepted - move down */
.chatbot-attention.cookie-hidden {
    bottom: 160px !important;
}

.chatbot-attention.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Arrow pointing down to button */
.chatbot-attention::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 24px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--chat-white);
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.05));
}

.chatbot-attention-text {
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    color: #333;
    line-height: 1.4;
    flex: 1;
}

.chatbot-attention-close {
    background: none;
    border: none;
    color: rgba(0, 0, 0, 0.4);
    cursor: pointer;
    padding: 4px;
    font-size: 12px;
    transition: color 0.2s ease;
    flex-shrink: 0;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-attention-close:hover {
    color: #333;
    background: rgba(0, 0, 0, 0.05);
}

/* ============================================ */
/* Chat Window                                  */
/* ============================================ */
.chatbot-window {
    position: fixed;
    bottom: calc(var(--chatbot-button-bottom) + var(--chatbot-button-size) + 16px);
    right: var(--floating-right);
    width: 380px;
    height: 520px;
    max-height: calc(100vh - var(--chatbot-button-bottom) - var(--chatbot-button-size) - 40px);
    background: var(--chat-background);
    border-radius: 20px;
    box-shadow: 0 10px 40px var(--chat-shadow-dark);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ============================================ */
/* Chat Header                                  */
/* ============================================ */
.chatbot-header {
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 70px;
    flex-shrink: 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--chat-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Playfair Display', serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--chat-primary-dark);
}

.chatbot-header-text h4 {
    color: var(--chat-white);
    font-family: 'Poppins', sans-serif;
    font-size: 16px;
    font-weight: 500;
    margin: 0 0 2px 0;
}

.chatbot-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Poppins', sans-serif;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
}

.chatbot-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4CAF50;
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chatbot-header-actions {
    display: flex;
    gap: 8px;
}

.chatbot-header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--chat-white);
    font-size: 16px;
    transition: all 0.2s ease;
}

.chatbot-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* ============================================ */
/* Messages Area                                */
/* ============================================ */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--chat-border);
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--chat-primary);
}

/* ============================================ */
/* Message Bubbles                              */
/* ============================================ */
.chatbot-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: messageSlideIn 0.3s ease;
}

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

.chatbot-message.bot {
    align-self: flex-start;
}

.chatbot-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chatbot-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Playfair Display', serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--chat-white);
    flex-shrink: 0;
}

.chatbot-message.user .chatbot-message-avatar {
    background: var(--chat-secondary);
}

.chatbot-message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chatbot-message-bubble {
    padding: 12px 16px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chatbot-message.bot .chatbot-message-bubble {
    background: var(--chat-white);
    color: var(--chat-secondary);
    border: 1px solid var(--chat-border);
    border-radius: 18px 18px 18px 4px;
}

.chatbot-message.user .chatbot-message-bubble {
    background: var(--chat-primary);
    color: var(--chat-white);
    border-radius: 18px 18px 4px 18px;
}

.chatbot-message-time {
    font-family: 'Poppins', sans-serif;
    font-size: 11px;
    color: var(--chat-gray);
    padding: 0 4px;
}

.chatbot-message.user .chatbot-message-time {
    text-align: right;
}

/* System Messages */
.chatbot-message.system {
    align-self: center;
    max-width: 90%;
}

.chatbot-message.system .chatbot-message-content {
    text-align: center;
}

.chatbot-message.system .system-bubble {
    background: #e8f5e9 !important;
    color: #2e7d32 !important;
    font-size: 0.85rem;
    padding: 10px 16px !important;
    border-radius: 15px !important;
    display: inline-block;
    border: 1px solid #c8e6c9 !important;
}

/* ============================================ */
/* Typing Indicator                             */
/* ============================================ */
.chatbot-typing {
    display: flex;
    gap: 10px;
    max-width: 85%;
    align-self: flex-start;
    animation: messageSlideIn 0.3s ease;
}

.chatbot-typing-bubble {
    background: var(--chat-white);
    border: 1px solid var(--chat-border);
    border-radius: 18px 18px 18px 4px;
    padding: 16px 20px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.chatbot-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chat-primary);
    animation: typingBounce 1.4s ease-in-out infinite;
}

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

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

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

/* ============================================ */
/* Quick Actions                                */
/* ============================================ */
.chatbot-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.chatbot-quick-btn {
    background: transparent;
    border: 1px solid var(--chat-primary);
    color: var(--chat-primary-dark);
    padding: 8px 16px;
    border-radius: 20px;
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chatbot-quick-btn:hover {
    background: var(--chat-primary);
    color: var(--chat-white);
    transform: translateY(-1px);
}

/* ============================================ */
/* Input Area                                   */
/* ============================================ */
.chatbot-input-area {
    padding: 16px 20px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    background: var(--chat-white);
    border-top: 1px solid var(--chat-border);
    display: flex;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
}

.chatbot-input-wrapper {
    flex: 1;
    position: relative;
}

.chatbot-input {
    width: 100%;
    padding: 12px 20px;
    border: 1px solid var(--chat-border);
    border-radius: 25px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    background: var(--chat-background);
}

.chatbot-input:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(212, 181, 160, 0.15);
}

.chatbot-input::placeholder {
    color: var(--chat-gray);
}

.chatbot-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.chatbot-send-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--chat-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--chat-white);
    font-size: 18px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chatbot-send-btn:hover:not(:disabled) {
    background: var(--chat-primary-dark);
    transform: scale(1.05);
}

.chatbot-send-btn:disabled {
    background: var(--chat-border);
    cursor: not-allowed;
}

/* ============================================ */
/* RESPONSIVE: Tablet/Mobile (768px)            */
/* Mobile stack: Cherry(bottom) → Chatbot → Bubble(top) */
/* ============================================ */
@media (max-width: 768px) {
    :root {
        --floating-right: 15px;
        --chatbot-button-size: 56px;
        --chatbot-bubble-max-width: 180px;
    }

    .chatbot-button {
        bottom: 160px !important;
        right: 15px !important;
        width: 56px;
        height: 56px;
    }

    .chatbot-button.cookie-hidden {
        bottom: 100px !important;
    }

    .chatbot-button i {
        font-size: 22px;
    }

    .chatbot-attention {
        bottom: 235px !important;
        right: 15px !important;
        max-width: 180px;
    }

    .chatbot-attention.cookie-hidden {
        bottom: 175px !important;
    }

    .chatbot-attention-text {
        font-size: 13px;
    }

    .chatbot-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 75vh;
        max-height: 650px;
        border-radius: 20px 20px 0 0;
    }

    .chatbot-header {
        padding: 14px 16px;
        min-height: 60px;
    }

    .chatbot-avatar {
        width: 38px;
        height: 38px;
        font-size: 18px;
    }

    .chatbot-header-text h4 {
        font-size: 15px;
    }

    .chatbot-messages {
        padding: 16px;
        gap: 12px;
    }

    .chatbot-message-bubble {
        padding: 10px 14px;
        font-size: 13px;
    }

    .chatbot-input-area {
        padding: 12px 16px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .chatbot-input {
        padding: 10px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .chatbot-send-btn {
        width: 42px;
        height: 42px;
    }

    .chatbot-quick-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* ============================================ */
/* RESPONSIVE: Small Mobile (480px)             */
/* ============================================ */
@media (max-width: 480px) {
    :root {
        --floating-right: 12px;
        --chatbot-button-size: 52px;
        --chatbot-button-bottom: 100px;
        --chatbot-bubble-bottom: 165px;
        --chatbot-bubble-max-width: 180px;
    }

    .chatbot-button i {
        font-size: 20px;
    }

    .chatbot-attention {
        padding: 10px 14px;
        gap: 6px;
    }

    .chatbot-attention-text {
        font-size: 12px;
    }

    .chatbot-attention-close {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }

    .chatbot-window {
        height: 80vh;
    }
}

/* ============================================ */
/* RESPONSIVE: Extra Small (380px)              */
/* ============================================ */
@media (max-width: 380px) {
    .chatbot-attention {
        display: none;
    }

    .chatbot-message {
        max-width: 90%;
    }
}

/* ============================================ */
/* Landscape Mode on Mobile                     */
/* ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .chatbot-window {
        height: 90vh;
        max-height: none;
    }
}

/* ============================================ */
/* Reduced Motion Preference                    */
/* ============================================ */
@media (prefers-reduced-motion: reduce) {
    .chatbot-button,
    .chatbot-window,
    .chatbot-message,
    .chatbot-attention {
        transition: none;
        animation: none;
    }

    .chatbot-typing-dot,
    .chatbot-status-dot,
    .chatbot-button::before {
        animation: none;
    }
}

/* ============================================ */
/* Print Styles - Hide All Floating UI          */
/* ============================================ */
@media print {
    .chatbot-button,
    .chatbot-window,
    .chatbot-attention {
        display: none !important;
    }
}
