/* ============================
   AutoBot Chat Assistant Styles
   ============================ */

/* Lock body scroll when chat is full-screen on mobile */
body.autobot-chat-open {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
}

/* Floating chat button */
#autobot-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #c0392b;
    border: none;
    cursor: pointer;
    z-index: 99999;
    box-shadow: 0 4px 16px rgba(0,0,0,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    padding: 0;
}

#autobot-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(0,0,0,0.45);
}

#autobot-fab img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    pointer-events: none;
}

/* Docked state — FAB is a child of the header icon slot */
#autobot-fab.autobot-fab-docked {
    position: static !important;
    width: 48px;
    height: 48px;
    box-shadow: none;
    background: #c0392b;
    pointer-events: none;
    flex-shrink: 0;
}

#autobot-fab.autobot-fab-docked img {
    width: 38px;
    height: 38px;
}

#autobot-fab.autobot-fab-docked:hover {
    transform: none;
    box-shadow: none;
}

/* Header icon slot */
#autobot-header-icon-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

/* Spin animation when user is typing */
#autobot-fab.autobot-animate img {
    animation: autobot-spin 0.6s ease-in-out;
}

@keyframes autobot-spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Chat window */
#autobot-window {
    position: fixed;
    width: 380px;
    max-height: 520px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    z-index: 99998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#autobot-window.autobot-open {
    display: flex;
    animation: autobot-slide-up 0.3s ease;
}

@keyframes autobot-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Header */
#autobot-header {
    background: linear-gradient(135deg, #1a1a1a 0%, #a0a0a0 100%);
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    cursor: grab;
    user-select: none;
    border-left: 4px solid #c0392b;
}

#autobot-header:active {
    cursor: grabbing;
}

#autobot-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

#autobot-header-title {
    font-size: 16px;
    font-weight: 600;
}

#autobot-header-subtitle {
    font-size: 11px;
    opacity: 0.85;
}

#autobot-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

#autobot-close:hover {
    opacity: 1;
}

/* Messages area */
#autobot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 340px;
    background: #f9f9f9;
}

.autobot-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
}

.autobot-msg-bot {
    background: #fff;
    color: #333;
    align-self: flex-start;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.autobot-msg-user {
    background: #c0392b;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.autobot-msg a {
    color: #c0392b;
    text-decoration: underline;
    font-weight: 600;
}

.autobot-msg-user a {
    color: #ffd;
}

/* Typing indicator */
.autobot-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    align-self: flex-start;
}

.autobot-typing span {
    width: 8px;
    height: 8px;
    background: #c0392b;
    border-radius: 50%;
    animation: autobot-dot-bounce 1.2s infinite;
}

.autobot-typing span:nth-child(2) { animation-delay: 0.2s; }
.autobot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes autobot-dot-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-6px); opacity: 1; }
}

/* Input area */
#autobot-input-area {
    display: flex;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
    background: #fff;
}

#autobot-input {
    flex: 1;
    border: none;
    padding: 12px 16px;
    font-size: 13px;
    outline: none;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#autobot-input::placeholder {
    color: #aaa;
}

#autobot-send {
    background: #c0392b;
    color: #fff;
    border: none;
    padding: 12px 18px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

#autobot-send:hover {
    background: #e74c3c;
}

/* Quick action chips */
.autobot-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.autobot-chip {
    background: #fef2f2;
    color: #c0392b;
    border: 1px solid #fca5a5;
    padding: 5px 10px;
    border-radius: 16px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.autobot-chip:hover {
    background: #c0392b;
    color: #fff;
}

/* ============================
   MOBILE / PHONE RESPONSIVE
   ============================ */

/* Tablet breakpoint */
@media (max-width: 768px) {
    #autobot-window {
        width: calc(100vw - 24px);
        max-height: 65vh;
    }
    #autobot-messages {
        max-height: 50vh;
    }
}

/* Phone breakpoint — full-screen takeover */
@media (max-width: 480px) {
    /* Chat goes full-screen on phones */
    #autobot-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 100%;
        border-radius: 0;
        z-index: 100000;
        /* Use dvh for dynamic viewport on mobile keyboards */
        height: 100vh;
        height: 100dvh;
    }

    /* Messages fill available space */
    #autobot-messages {
        max-height: none;
        flex: 1;
        padding: 12px;
        /* Leave room for safe area at bottom */
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    /* Bigger header for touch */
    #autobot-header {
        padding: 16px 18px;
        padding-top: calc(16px + env(safe-area-inset-top, 0px));
    }

    #autobot-header-title {
        font-size: 18px;
    }

    /* Close button — larger touch target */
    #autobot-close {
        font-size: 28px;
        padding: 8px 12px;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Input area — prevent iOS zoom (must be >= 16px) */
    #autobot-input-area {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    #autobot-input {
        font-size: 16px;
        padding: 14px 16px;
        min-height: 48px;
    }

    /* Send button — large touch target */
    #autobot-send {
        padding: 14px 20px;
        font-size: 18px;
        min-width: 52px;
        min-height: 48px;
    }

    /* Messages — slightly larger text for readability */
    .autobot-msg {
        font-size: 14px;
        max-width: 88%;
        padding: 12px 14px;
    }

    /* Chips — bigger touch targets */
    .autobot-chip {
        font-size: 13px;
        padding: 8px 14px;
        min-height: 36px;
        display: inline-flex;
        align-items: center;
    }

    /* Hide FAB when chat is open on mobile */
    body.autobot-chat-open #autobot-fab {
        display: none !important;
    }

    /* FAB — slightly smaller on phone */
    #autobot-fab {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    #autobot-fab img {
        width: 40px;
        height: 40px;
    }
}

/* Handle landscape orientation on phones */
@media (max-width: 480px) and (orientation: landscape) {
    #autobot-messages {
        max-height: none;
        flex: 1;
    }
    #autobot-header {
        padding: 8px 18px;
    }
    .autobot-msg {
        font-size: 13px;
        padding: 8px 12px;
    }
}
