/* ============================================
   SISTEMA DE CHAT ESTILO WHATSAPP - STYLES
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Colores principales - AyuntaClaro Institucional */
    --primary: #2563eb;
    /* Azul Institucional Moderno */
    --primary-dark: #1e40af;
    --primary-light: #eff6ff;
    --accent: #0ea5e9;
    /* Celeste Tecnológico */

    /* Gradientes institucionales */
    --primary-gradient: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    --secondary-gradient: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
    --success-gradient: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);

    /* Colores de chat */
    --user-bubble: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    --bot-bubble: #f8fafc;
    --bot-text: #0f172a;
    --user-text: #ffffff;

    /* Fondo */
    --bg-gradient: linear-gradient(180deg, #eff6ff 0%, #f8fafc 100%);
    --chat-pattern: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%232563eb' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");

    /* Colores oscuros */
    --dark: #0f172a;
    --slate: #475569;

    /* Sombras */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 10px 40px -10px rgba(0, 0, 0, 0.15);

    /* Espaciado */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Bordes */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-bubble: 16px;
}

/* ============================================
   RESET Y BASE
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: #1f1f1f;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ============================================
   HEADER
   ============================================ */

.chat-header {
    background: var(--primary-gradient);
    padding: var(--spacing-md) var(--spacing-lg);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.header-logo {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-logo:hover {
    transform: translateY(-2px);
    filter: brightness(1.2);
}

.header-logo::before {
    content: "💬";
    font-size: 1.8rem;
}

/* ============================================
   LANGUAGE SELECTOR
   ============================================ */

.language-selector {
    margin-left: auto;
}

.language-select {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    color: white;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

.language-select:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.language-select:focus {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

.language-select option {
    background: var(--primary);
    color: white;
    padding: 8px;
}

/* ============================================
   CHAT CONTAINER
   ============================================ */

.chat-container {
    max-width: 900px;
    margin: var(--spacing-lg) auto;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 500px;
}

/* ============================================
   MESSAGES AREA
   ============================================ */

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-lg);
    background-image: var(--chat-pattern);
    background-color: #fafafa;
    scroll-behavior: smooth;
}

.messages-area::-webkit-scrollbar {
    width: 8px;
}

.messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.messages-area::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.messages-area::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* ============================================
   MESSAGE BUBBLES
   ============================================ */

.message {
    display: flex;
    margin-bottom: var(--spacing-md);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    justify-content: flex-end;
}

.message.bot {
    justify-content: flex-start;
}

.bubble {
    max-width: 70%;
    padding: 12px 18px;
    border-radius: var(--radius-bubble);
    position: relative;
    word-wrap: break-word;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(10px);
}

.bubble.user {
    background: var(--user-bubble);
    color: var(--user-text);
    border-bottom-right-radius: 4px;
    animation: bubblePopUser 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.bubble.bot {
    background: var(--bot-bubble);
    color: var(--bot-text);
    border-bottom-left-radius: 4px;
    animation: bubblePopBot 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bubblePopUser {
    0% {
        opacity: 0;
        transform: scale(0.5) translateX(20px);
    }

    70% {
        transform: scale(1.05) translateX(0);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateX(0);
    }
}

@keyframes bubblePopBot {
    0% {
        opacity: 0;
        transform: scale(0.5) translateX(-20px);
    }

    70% {
        transform: scale(1.05) translateX(0);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateX(0);
    }
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 4px;
    display: block;
}

/* ============================================
   TYPING INDICATOR
   ============================================ */

.typing-indicator {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 12px 18px;
    background: var(--bot-bubble);
    border-radius: var(--radius-bubble);
    border-bottom-left-radius: 4px;
    max-width: 70px;
    box-shadow: var(--shadow-sm);
}

.typing-indicator.active {
    display: flex;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-10px);
    }
}

/* ============================================
   INPUT AREA
   ============================================ */

.input-area {
    padding: var(--spacing-md);
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.message-input {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.message-input:focus {
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.send-button {
    padding: 14px 28px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 25px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 8px;
}

.send-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.send-button:active {
    transform: translateY(0);
}

.send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.send-button::after {
    content: "➤";
    font-size: 1.1rem;
}

/* ============================================
   FOOTER
   ============================================ */

.chat-footer {
    background: var(--dark);
    padding: var(--spacing-md) var(--spacing-lg);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-left {
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
}

.back-button {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    color: white;
    text-decoration: none;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateX(-3px);
}

.back-button::before {
    content: "← ";
}

.footer-credits {
    font-size: 0.9rem;
    opacity: 0.9;
}

.footer-credits a {
    color: #4facfe;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

.footer-credits a:hover {
    color: #00f2fe;
    text-decoration: underline;
}

/* ============================================
   ESTADOS Y UTILIDADES
   ============================================ */

.error-message {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    margin: var(--spacing-sm) 0;
    box-shadow: var(--shadow-sm);
    animation: shake 0.5s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

.welcome-message {
    text-align: center;
    padding: var(--spacing-xl);
    color: #666;
    font-style: italic;
}

.welcome-message::before {
    content: "👋";
    display: block;
    font-size: 3rem;
    margin-bottom: var(--spacing-sm);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .chat-container {
        margin: 0;
        border-radius: 0;
        height: calc(100vh - 140px);
    }

    .bubble {
        max-width: 85%;
    }

    .header-logo {
        font-size: 1.2rem;
    }

    .chat-footer {
        flex-direction: column;
        text-align: center;
    }

    .footer-left {
        width: 100%;
        justify-content: center;
    }

    .messages-area {
        padding: var(--spacing-sm);
    }
}

@media (max-width: 480px) {
    .send-button {
        padding: 14px 20px;
    }

    .send-button span {
        display: none;
    }

    .message-input {
        font-size: 16px;
        /* Previene zoom en iOS */
    }
}

/* ============================================
   ANIMACIONES ADICIONALES
   ============================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

/* Efecto glassmorphism para elementos especiales */
.glass {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}