/* ============================================
   ULTIMATE ASTRO SUPPORT ASSISTANT - OVERHAULED
   ============================================ */

:root {
    --chat-primary: #591C21;
    --chat-primary-gradient: linear-gradient(135deg, #591C21 0%, #832C33 100%);
    --chat-secondary: #F0A500;
    --chat-bg: #FFFFFF;
    --chat-bot-bubble: #FFFFFF;
    --chat-user-bubble: #591C21;
    --chat-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    --chat-radius: 16px;
    --chat-font: 'Poppins', sans-serif;
    --chat-z-index: 100002;
    /* Extremely high to stay above everything */
}

/* Chat Toggle Button - Floating & Bobbing */
.astro-chat-toggle {
    position: fixed;
    bottom: 30px;
    right: 40px;
    width: 85px;
    height: 85px;
    background: transparent;
    border-radius: 50%;
    box-shadow: none;
    cursor: pointer;
    z-index: var(--chat-z-index);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: none;
    overflow: visible;
    animation: astroBotBob 3s ease-in-out infinite;
}

.astro-toggle-badge {
    position: absolute;
    top: -10px;
    right: -5px;
    background: var(--chat-primary);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    animation: astro-pulse 2s infinite;
}

@keyframes astro-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(89, 28, 33, 0.4);
    }

    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 10px rgba(89, 28, 33, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(89, 28, 33, 0);
    }
}

.astro-chat-toggle:active {
    cursor: grabbing;
}

@keyframes astroBotBob {
    0% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0);
    }
}

.astro-chat-toggle:hover {
    transform: scale(1.1);
    animation-play-state: paused;
}

.astro-chat-toggle img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: absolute;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.astro-chat-toggle.left-side img {
    transform: scaleX(-1);
}

.astro-chat-toggle .bot-img-active {
    opacity: 0;
}

.astro-chat-toggle.active .bot-img-default {
    opacity: 0;
}

.astro-chat-toggle.active .bot-img-active {
    opacity: 1;
}

/* Main Chat Container */
.astro-chat-container {
    position: fixed;
    bottom: 90px;
    right: 88px;
    width: 350px;
    /* Default desktop width */
    height: 500px;
    max-height: 80vh;
    background: var(--chat-bg);
    border-radius: var(--chat-radius);
    /* Enhanced 3D Shadow */
    box-shadow:
        0 10px 40px -10px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    z-index: calc(var(--chat-z-index) + 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform: scale(0.8) translateY(50px);
    opacity: 0;
    pointer-events: none;
    transform-origin: bottom right;
}

.astro-chat-container.open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

/* Header - non-draggable */
.astro-chat-header {
    background: var(--chat-primary-gradient);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: default;
    user-select: none;
    flex-shrink: 0;
}

/* Removed active state for grabbing */

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

.astro-chat-header-info img {
    width: 32px;
    height: 32px;
    background: white;
    border-radius: 50%;
    padding: 2px;
    object-fit: contain;
}

.astro-chat-header h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

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

.astro-chat-header-actions button {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 1;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.astro-chat-header-actions .astro-btn-new {
    width: auto;
    height: auto;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.15);
    margin-right: 5px;
    opacity: 0.9;
    white-space: nowrap;
}

.astro-chat-header-actions .astro-btn-new:hover {
    background: rgba(255, 255, 255, 0.25);
    opacity: 1;
}

.astro-chat-header-actions button:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

/* Message Area */
.astro-chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #F8F9FA;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #DDD transparent;
}

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

.astro-chat-messages::-webkit-scrollbar-thumb {
    background: #DDD;
    border-radius: 10px;
}

/* Bubbles */
.chat-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    animation: slideIn 0.3s ease-out;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bot-bubble {
    align-self: flex-start;
    background: #FFFFFF;
    color: #333;
    border-bottom-left-radius: 4px;
}

.user-bubble {
    align-self: flex-end;
    background: var(--chat-primary-gradient);
    color: #FFFFFF;
    border-bottom-right-radius: 4px;
}

/* Quick Replies */
.chat-btn-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 5px;
}

.chat-btn {
    background: white;
    border: 1.5px solid var(--chat-primary);
    color: var(--chat-primary);
    padding: 10px 15px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: left;
    transition: all 0.2s;
    width: fit-content;
}

.chat-btn:hover {
    background: var(--chat-primary);
    color: white;
    transform: translateX(5px);
}

/* Typing Indicator */
.typing-indicator {
    padding: 10px 15px;
    background: #FFFFFF;
    border-radius: 15px;
    width: fit-content;
    display: flex;
    gap: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.dot {
    width: 6px;
    height: 6px;
    background: #888;
    border-radius: 50%;
    animation: dotBounce 1.4s infinite ease-in-out;
}

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

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

@keyframes dotBounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-5px);
    }
}

/* Input Area */
.astro-chat-input-wrapper {
    padding: 15px;
    background: white;
    border-top: 1px solid #EEE;
    display: none;
    align-items: center;
    gap: 10px;
    box-sizing: border-box;
    width: 100%;
}

.astro-chat-input-wrapper.active {
    display: flex;
}

.astro-chat-input-wrapper input {
    flex-grow: 1;
    border: 1px solid #DDD;
    border-radius: 25px;
    padding: 10px 18px;
    outline: none;
    font-size: 0.9rem;
    font-family: inherit;
    box-sizing: border-box;
    width: 0;
    /* Let flex-grow handle the width */
}

.astro-chat-send {
    background: var(--chat-primary-gradient);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.astro-chat-send:active {
    transform: scale(0.9);
}

/* Responsive Queries */

/* Desktop (13" - 17") */
@media screen and (min-width: 1025px) {
    .astro-chat-container {
        width: 350px;
        max-width: 380px;
    }
}

/* Tablet (6" - 12") */
@media screen and (min-width: 601px) and (max-width: 1024px) {
    .astro-chat-container {
        width: 60%;
        max-width: 400px;
        height: 60vh;
    }
}

/* Mobile (5" - 7") */
@media screen and (max-width: 600px) {
    .astro-chat-container {
        width: 85%;
        height: auto;
        max-height: calc(100vh - 120px);
        /* Leave room for mobile header */
        bottom: 90px;
        right: 20px;
        /* Default starting position */
        transform-origin: bottom center;
        border-radius: 12px;
    }

    .astro-chat-toggle {
        bottom: 20px;
        /* Keep above navigation bars/floating buttons */
        right: 15px;
        width: 55px;
        height: 55px;
    }
}

/* Form Styles */
.chat-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.form-row {
    display: flex;
    gap: 8px;
}

.form-input,
.form-select,
.form-textarea {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ddd;
    font-family: inherit;
    font-size: 0.9rem;
    width: 100%;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
    /* Ensure padding doesn't affect width */
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 2px rgba(var(--chat-primary-rgb), 0.1);
}

.form-select {
    width: 35%;
    /* Fixed width for country code */
    min-width: 90px;
    background: white;
    cursor: pointer;
}

.form-btn {
    background: var(--chat-primary-gradient);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    margin-top: 5px;
    text-align: center;
}

.form-btn:hover {
    opacity: 0.95;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.form-btn:active {
    transform: translateY(0);
}

.form-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Mobile specific open state */
@media screen and (max-width: 600px) {
    .astro-chat-container.open {
        transform: translateY(-80px) scale(1);
    }
}

/* ============================================
   FLOATING TICKETS (From Chatbot)
   ============================================ */
.astro-floating-ticket {
    position: fixed;
    z-index: 100000;
    width: 100px;
    background: #591C21;
    /* Maroon */
    color: #FFD700;
    /* Golden */
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none !important;
    font-family: 'Poppins', sans-serif;
    font-weight: 800;
    /* Simulate the inner dashed border via box-shadow/outline isn't always easy, we'll use a pseudo element */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 2px solid #FFD700;
    /* Golden Outer Border */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    opacity: 0;
    animation: floatTicketUp 7s linear forwards;

    /* Ticket cutouts */
    -webkit-mask-image: radial-gradient(circle at 0 50%, transparent 6px, black 7px), radial-gradient(circle at 100% 50%, transparent 6px, black 7px);
    -webkit-mask-position: left, right;
    -webkit-mask-size: 51% 100%;
    -webkit-mask-repeat: no-repeat;
    mask-image: radial-gradient(circle at 0 50%, transparent 6px, black 7px), radial-gradient(circle at 100% 50%, transparent 6px, black 7px);
    mask-position: left, right;
    mask-size: 51% 100%;
    mask-repeat: no-repeat;
}

.astro-floating-ticket::before {
    content: '';
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 8px;
    right: 8px;
    border: 1px dashed rgba(255, 215, 0, 0.6);
    /* Golden dashed inner border */
    pointer-events: none;
}

.astro-floating-ticket:hover {
    filter: brightness(1.1) drop-shadow(0 0 10px rgba(255, 215, 0, 0.8));
    animation-play-state: paused;
}

.astro-floating-ticket .ticket-stars {
    font-size: 11px;
    line-height: 1;
    color: #000;
    letter-spacing: 2px;
}

.astro-floating-ticket .ticket-text {
    font-size: 14px;
    line-height: 1.1;
    letter-spacing: 0.5px;
}

@keyframes floatTicketUp {
    0% {
        opacity: 0;
        bottom: var(--start-y);
        left: var(--start-x);
        transform: scale(0.5);
    }

    5% {
        opacity: 1;
        bottom: calc(var(--start-y) + 20px);
        left: var(--start-x);
        transform: scale(1) rotate(-5deg);
    }

    65% {
        opacity: 1;
        bottom: calc(var(--start-y) + (var(--end-y) - var(--start-y)) * 0.7);
        left: calc(var(--start-x) + var(--drift-x) * 0.7);
        transform: scale(1) rotate(3deg);
    }

    90% {
        opacity: 0;
        bottom: var(--end-y);
        left: calc(var(--start-x) + var(--drift-x));
        transform: scale(0.7) rotate(5deg);
    }

    100% {
        opacity: 0;
        bottom: calc(var(--end-y) + 20px);
        left: calc(var(--start-x) + var(--drift-x));
        transform: scale(0.5);
    }
}