/* ═══════════════════════════════════════════════════════════════
   Chatbot Ayuntamiento de El Ejido — "Ejido Concierge"
   Design System: Institutional Glassmorphism
   Stitch-enhanced premium frontend styles
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ───────── Design Tokens ───────── */
:root {
    --cb-primary: #264B77;
    --cb-primary-light: #3a6ba5;
    --cb-primary-dark: #06345f;
    --cb-primary-rgb: 38, 75, 119;
    --cb-secondary: #2d6099;
    --cb-surface: #faf9fd;
    --cb-surface-container: #eeedf2;
    --cb-surface-high: #e8e8ec;
    --cb-surface-low: #f4f3f7;
    --cb-bg: #f0f2f5;
    --cb-card: #ffffff;
    --cb-text: #1a1c1f;
    --cb-text-secondary: #43474f;
    --cb-text-muted: #737780;
    --cb-border: #c3c6d0;
    --cb-border-light: rgba(0,0,0,0.05);
    --cb-accent: #a6c9fc;
    --cb-success: #4ade80;
    --cb-radius: 16px;
    --cb-radius-sm: 8px;
    --cb-radius-full: 9999px;
    --cb-shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 4px 15px rgba(0,0,0,0.06);
    --cb-shadow: 0 4px 20px rgba(0,0,0,0.1), 0 8px 32px rgba(0,0,0,0.06);
    --cb-shadow-lg: 0 8px 40px rgba(0,0,0,0.14), 0 16px 56px rgba(0,0,0,0.08);
    --cb-shadow-float: 0 12px 48px rgba(var(--cb-primary-rgb), 0.25);
    --cb-transition: 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    --cb-transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --cb-glass-bg: rgba(255,255,255,0.85);
    --cb-glass-blur: blur(20px);
    --cb-glass-border: 1px solid rgba(255,255,255,0.6);
}

/* ───────── Widget Container ───────── */
#chatbot-ayto-widget {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 99999;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#chatbot-ayto-widget *,
#chatbot-ayto-widget *::before,
#chatbot-ayto-widget *::after {
    box-sizing: border-box;
    margin: 0;
}

/* ───────── FAB Toggle Button ───────── */
#chatbot-ayto-toggle {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-primary-light) 100%) !important;
    box-shadow: var(--cb-shadow-float), 0 0 0 0 rgba(var(--cb-primary-rgb), 0);
    transition: all var(--cb-transition);
    position: relative;
    overflow: hidden;
}

#chatbot-ayto-toggle::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 60%);
    opacity: 0;
    transition: opacity var(--cb-transition-fast);
}

#chatbot-ayto-toggle:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: var(--cb-shadow-float), 0 0 0 8px rgba(var(--cb-primary-rgb), 0.12);
}

#chatbot-ayto-toggle:hover::before {
    opacity: 1;
}

#chatbot-ayto-toggle:active {
    transform: scale(0.95);
}

.chatbot-ayto-icon-chat,
.chatbot-ayto-icon-close {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: absolute;
}

.chatbot-ayto-icon-close {
    transform: rotate(-90deg) scale(0);
    opacity: 0;
}

#chatbot-ayto-widget.open .chatbot-ayto-icon-chat {
    transform: rotate(90deg) scale(0);
    opacity: 0;
}

#chatbot-ayto-widget.open .chatbot-ayto-icon-close {
    transform: rotate(0deg) scale(1);
    opacity: 1;
}

/* Badge */
.chatbot-ayto-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2.5px solid #fff;
    animation: chatbot-badge-pulse 2s ease-in-out infinite;
    box-shadow: 0 2px 6px rgba(239,68,68,0.4);
}

@keyframes chatbot-badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* FAB Pulse on load */
#chatbot-ayto-toggle {
    animation: chatbot-fab-pulse 3s ease-in-out 2s 3;
}

@keyframes chatbot-fab-pulse {
    0%, 100% { box-shadow: var(--cb-shadow-float), 0 0 0 0 rgba(var(--cb-primary-rgb), 0); }
    50% { box-shadow: var(--cb-shadow-float), 0 0 0 14px rgba(var(--cb-primary-rgb), 0.12); }
}

/* ───────── Chat Window ───────── */
#chatbot-ayto-window {
    position: absolute;
    bottom: 76px;
    left: 0;
    width: 400px;
    max-height: 600px;
    background: var(--cb-surface);
    border-radius: 20px;
    box-shadow: var(--cb-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: bottom left;
    border: 1px solid rgba(0,0,0,0.06);
}

#chatbot-ayto-window.chatbot-ayto-hidden {
    opacity: 0;
    transform: scale(0.8) translateY(24px);
    pointer-events: none;
    visibility: hidden;
}

#chatbot-ayto-window:not(.chatbot-ayto-hidden) {
    opacity: 1;
    transform: scale(1) translateY(0);
    visibility: visible;
}

/* ───────── Header — Glassmorphic ───────── */
.chatbot-ayto-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    color: #fff;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--cb-primary-dark) 0%, var(--cb-primary) 40%, var(--cb-primary-light) 100%) !important;
}

/* Decorative circles */
.chatbot-ayto-header::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -20px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,0.07);
    pointer-events: none;
}

.chatbot-ayto-header::after {
    content: '';
    position: absolute;
    bottom: -40px;
    left: 30%;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
    pointer-events: none;
}

.chatbot-ayto-header-info {
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 1;
}

.chatbot-ayto-header-logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    object-fit: cover;
    background: rgba(255,255,255,0.18);
    padding: 4px;
    flex-shrink: 0;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.15);
}

.chatbot-ayto-header-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.chatbot-ayto-header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    opacity: 0.88;
    margin-top: 3px;
    letter-spacing: 0.01em;
}

.chatbot-ayto-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cb-success);
    display: inline-block;
    box-shadow: 0 0 6px rgba(74,222,128,0.6);
    animation: chatbot-dot-glow 2s ease-in-out infinite;
}

@keyframes chatbot-dot-glow {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px rgba(74,222,128,0.6); }
    50% { opacity: 0.6; box-shadow: 0 0 3px rgba(74,222,128,0.3); }
}

.chatbot-ayto-header-close {
    background: rgba(255,255,255,0.12);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    cursor: pointer;
    padding: 7px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--cb-transition-fast);
    z-index: 1;
}

.chatbot-ayto-header-close:hover {
    background: rgba(255,255,255,0.22);
    transform: scale(1.05);
}

/* ───────── Messages Area ───────── */
.chatbot-ayto-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--cb-bg);
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 320px;
    max-height: 400px;
    scroll-behavior: smooth;
}

/* Custom scrollbar */
.chatbot-ayto-messages::-webkit-scrollbar {
    width: 5px;
}
.chatbot-ayto-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chatbot-ayto-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.12);
    border-radius: 10px;
}
.chatbot-ayto-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.2);
}

/* ───────── Message Bubbles ───────── */
.chatbot-ayto-msg {
    display: flex;
    gap: 10px;
    max-width: 88%;
    animation: chatbot-msg-appear 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes chatbot-msg-appear {
    from { opacity: 0; transform: translateY(14px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.chatbot-ayto-msg.bot { align-self: flex-start; }
.chatbot-ayto-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.chatbot-ayto-msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    margin-top: 2px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.chatbot-ayto-msg-avatar.user-avatar {
    background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

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

.chatbot-ayto-msg-bubble {
    padding: 13px 18px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    position: relative;
    letter-spacing: -0.005em;
}

/* Bot bubble — Glassmorphic Surface */
.chatbot-ayto-msg.bot .chatbot-ayto-msg-bubble {
    background: var(--cb-card);
    color: var(--cb-text);
    border-radius: 16px 16px 16px 4px;
    box-shadow: var(--cb-shadow-sm);
    border: 1px solid var(--cb-border-light);
}

/* User bubble — Gradient Pill */
.chatbot-ayto-msg.user .chatbot-ayto-msg-bubble {
    background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-primary-light) 100%);
    color: #fff;
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 2px 12px rgba(var(--cb-primary-rgb), 0.2);
}

.chatbot-ayto-msg-bubble a {
    color: var(--cb-secondary);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid rgba(45,96,153,0.3);
    transition: border-color var(--cb-transition-fast);
}

.chatbot-ayto-msg-bubble a:hover {
    border-bottom-color: var(--cb-secondary);
}

.chatbot-ayto-msg.user .chatbot-ayto-msg-bubble a {
    color: var(--cb-accent);
    border-bottom-color: rgba(166,201,252,0.4);
}

.chatbot-ayto-msg-time {
    font-size: 11px;
    color: var(--cb-text-muted);
    padding: 0 4px;
    font-weight: 500;
    letter-spacing: 0.03em;
}

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

/* ───────── Typing Indicator ───────── */
.chatbot-ayto-typing {
    display: flex;
    align-items: center;
    gap: 10px;
    align-self: flex-start;
    max-width: 88%;
    animation: chatbot-msg-appear 0.35s ease;
}

.chatbot-ayto-typing-dots {
    background: var(--cb-card);
    padding: 14px 22px;
    border-radius: 16px 16px 16px 4px;
    box-shadow: var(--cb-shadow-sm);
    border: 1px solid var(--cb-border-light);
    display: flex;
    gap: 6px;
    align-items: center;
}

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

.chatbot-ayto-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.chatbot-ayto-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatbot-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
    30% { transform: translateY(-8px); opacity: 1; background: var(--cb-primary-light); }
}

/* ───────── Quick Replies — Pill Buttons ───────── */
.chatbot-ayto-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 4px 0;
    animation: chatbot-msg-appear 0.5s ease 0.15s both;
}

.chatbot-ayto-suggestion-btn {
    background: var(--cb-card);
    border: 1.5px solid var(--cb-border);
    color: var(--cb-primary);
    padding: 9px 18px;
    border-radius: var(--cb-radius-full);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--cb-transition);
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
    letter-spacing: -0.01em;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.chatbot-ayto-suggestion-btn:hover {
    background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-primary-light) 100%);
    color: #fff;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(var(--cb-primary-rgb), 0.3);
}

.chatbot-ayto-suggestion-btn:active {
    transform: translateY(0) scale(0.97);
}

/* ───────── Input Area — Glass Footer ───────── */
.chatbot-ayto-input-area {
    display: flex;
    gap: 10px;
    padding: 14px 16px;
    background: var(--cb-glass-bg);
    backdrop-filter: var(--cb-glass-blur);
    -webkit-backdrop-filter: var(--cb-glass-blur);
    border-top: 1px solid rgba(0,0,0,0.05);
    align-items: center;
}

#chatbot-ayto-input {
    flex: 1;
    padding: 11px 18px;
    border: 1.5px solid var(--cb-border);
    border-radius: var(--cb-radius-full);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    color: var(--cb-text);
    background: var(--cb-surface);
    outline: none;
    transition: all var(--cb-transition-fast);
    letter-spacing: -0.005em;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.03);
}

#chatbot-ayto-input:focus {
    border-color: var(--cb-primary);
    box-shadow: 0 0 0 4px rgba(var(--cb-primary-rgb), 0.08), inset 0 1px 3px rgba(0,0,0,0.02);
    background: #fff;
}

#chatbot-ayto-input::placeholder {
    color: var(--cb-text-muted);
    font-weight: 400;
}

#chatbot-ayto-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--cb-transition);
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-primary-light) 100%) !important;
    box-shadow: 0 2px 8px rgba(var(--cb-primary-rgb), 0.2);
}

#chatbot-ayto-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(var(--cb-primary-rgb), 0.35);
}

#chatbot-ayto-send:active {
    transform: scale(0.92);
}

/* ───────── Powered By Footer ───────── */
.chatbot-ayto-powered {
    text-align: center;
    padding: 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--cb-text-muted);
    background: var(--cb-surface);
    border-top: 1px solid rgba(0,0,0,0.03);
    letter-spacing: 0.02em;
}

/* ───────── Mobile Responsive ───────── */
@media (max-width: 480px) {
    #chatbot-ayto-widget {
        bottom: 16px;
        left: 16px;
        right: 16px;
    }

    #chatbot-ayto-window {
        width: calc(100vw - 32px);
        max-height: calc(100vh - 120px);
        bottom: 76px;
        left: 0;
        right: 0;
        border-radius: 16px;
    }

    .chatbot-ayto-messages {
        max-height: calc(100vh - 280px);
    }

    #chatbot-ayto-toggle {
        width: 54px;
        height: 54px;
    }
}

@media (max-width: 400px) {
    .chatbot-ayto-header { padding: 14px 16px; }
    .chatbot-ayto-header-logo { width: 38px; height: 38px; }
    .chatbot-ayto-header-title { font-size: 14px; }
    .chatbot-ayto-msg-bubble { padding: 11px 15px; font-size: 13px; }
    .chatbot-ayto-suggestion-btn { padding: 7px 14px; font-size: 12px; }
}

/* ───────── Print: hide ───────── */
@media print {
    #chatbot-ayto-widget { display: none !important; }
}
