/*
 * ═══════════════════════════════════════════════════════════════
 *   CHAT COUNTRY HOMES - ESTILOS PREMIUM
 * ═══════════════════════════════════════════════════════════════
 * 
 * Paleta de colores REAL de Country Homes
 * 
 * Colores principales:
 * - #5B8C3E (Verde principal - color de marca)
 * - #4A7332 (Verde oscuro - hover/sombras)
 * - #6FA851 (Verde claro - acentos)
 * - #FFFFFF (Blanco - fondos y textos)
 * - #F8F9FA (Gris muy claro - fondos secundarios)
 * - #2C3E50 (Gris oscuro - textos)
 * 
 * Tipografía:
 * - Playfair Display (títulos, elegante)
 * - Lato (cuerpo, legible)
 */

/* ═══════════════════════════════════════════════════════════════
   RESET Y BASE
   ═══════════════════════════════════════════════════════════════ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colores de marca REALES */
    --primary-green: #5B8C3E;
    --primary-green-dark: #4A7332;
    --primary-green-light: #6FA851;
    --accent-green-bright: #7CB342;
    
    /* Neutrales */
    --bg-white: #FFFFFF;
    --bg-light-gray: #F8F9FA;
    --bg-cream: #F5F7F5;
    --text-dark: #2C3E50;
    --text-medium: #546E7A;
    --text-light: #90A4AE;
    
    /* Sombras */
    --shadow-sm: 0 2px 8px rgba(91, 140, 62, 0.1);
    --shadow-md: 0 4px 16px rgba(91, 140, 62, 0.15);
    --shadow-lg: 0 8px 32px rgba(91, 140, 62, 0.2);
    
    /* Bordes */
    --border-radius: 12px;
    --border-radius-lg: 20px;
    
    /* Tipografía */
    --font-display: 'Playfair Display', serif;
    --font-body: 'Lato', sans-serif;
    
    /* Espaciado */
    --spacing-xs: 8px;
    --spacing-sm: 12px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
}

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, #F5F7F5 0%, #E8F5E9 100%);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
    position: relative;
    overflow-x: hidden;
}

/* Overlay decorativo de fondo */
.background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(91, 140, 62, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(111, 168, 81, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ═══════════════════════════════════════════════════════════════
   CONTENEDOR PRINCIPAL DEL CHAT
   ═══════════════════════════════════════════════════════════════ */

.chat-container {
    width: 100%;
    max-width: 900px;
    height: 700px;
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ═══════════════════════════════════════════════════════════════
   HEADER DEL CHAT
   ═══════════════════════════════════════════════════════════════ */

.chat-header {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-dark) 100%);
    color: white;
    padding: var(--spacing-lg);
    border-bottom: 3px solid var(--primary-green-light);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.logo-icon {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.header-text h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.5px;
}

.subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
    margin: 4px 0 0 0;
    font-weight: 300;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 12px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4ADE80;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

.status-text {
    font-weight: 400;
}

/* ═══════════════════════════════════════════════════════════════
   ÁREA DE MENSAJES
   ═══════════════════════════════════════════════════════════════ */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-lg);
    background: var(--bg-cream);
    background-image: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 50px,
            rgba(91, 140, 62, 0.02) 50px,
            rgba(91, 140, 62, 0.02) 51px
        );
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(91, 140, 62, 0.05);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--primary-green-light);
    border-radius: 4px;
    transition: background 0.3s;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--primary-green);
}

/* ═══════════════════════════════════════════════════════════════
   MENSAJES
   ═══════════════════════════════════════════════════════════════ */

.message-wrapper {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message-wrapper {
    justify-content: flex-end;
}

.bot-message-wrapper {
    justify-content: flex-start;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bot-avatar {
    background: linear-gradient(135deg, var(--primary-green), var(--primary-green-dark));
}

.user-avatar {
    background: linear-gradient(135deg, var(--primary-green-light), var(--accent-green-bright));
}

.message {
    max-width: 70%;
    position: relative;
}

.message-content {
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--border-radius);
    line-height: 1.6;
    font-size: 0.95rem;
}

.message-content p {
    margin: 0 0 var(--spacing-sm) 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content strong {
    color: var(--primary-green-dark);
    font-weight: 600;
}

.bot-message .message-content {
    background: white;
    color: var(--text-dark);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(91, 140, 62, 0.1);
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-dark) 100%);
    color: white;
    box-shadow: var(--shadow-md);
}

.message-time {
    display: block;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: var(--spacing-xs);
    padding-left: var(--spacing-lg);
}

.user-message .message-time {
    text-align: right;
    padding-right: var(--spacing-lg);
    padding-left: 0;
    color: rgba(255, 255, 255, 0.7);
}

/* ═══════════════════════════════════════════════════════════════
   INDICADOR DE ESCRITURA
   ═══════════════════════════════════════════════════════════════ */

.typing-indicator {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
    padding: 0 var(--spacing-lg) var(--spacing-md);
    animation: slideIn 0.3s ease-out;
}

.typing-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-green), var(--primary-green-dark));
    display: flex;
    align-items: center;
    justify-content: center;
}

.typing-dots {
    background: white;
    padding: 12px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 6px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--primary-green);
    border-radius: 50%;
    animation: typingDot 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ═══════════════════════════════════════════════════════════════
   ÁREA DE INPUT
   ═══════════════════════════════════════════════════════════════ */

.chat-input-area {
    background: white;
    border-top: 1px solid rgba(91, 140, 62, 0.1);
    padding: var(--spacing-md);
}

.input-container {
    display: flex;
    gap: var(--spacing-sm);
    align-items: flex-end;
    background: var(--bg-cream);
    border-radius: var(--border-radius);
    padding: var(--spacing-sm);
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.input-container:focus-within {
    border-color: var(--primary-green);
    background: white;
    box-shadow: var(--shadow-sm);
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--text-dark);
    resize: none;
    max-height: 120px;
    padding: var(--spacing-sm);
    outline: none;
}

#messageInput::placeholder {
    color: var(--text-light);
}

.send-button {
    width: 45px;
    height: 45px;
    border: none;
    background: linear-gradient(135deg, var(--primary-green), var(--primary-green-dark));
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-green-dark), #3A5A28);
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.send-button:active:not(:disabled) {
    transform: scale(0.95);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-footer {
    margin-top: var(--spacing-sm);
}

.disclaimer {
    font-size: 0.75rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.disclaimer svg {
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   FOOTER DE CONTACTO
   ═══════════════════════════════════════════════════════════════ */

.contact-footer {
    width: 100%;
    max-width: 900px;
    margin-top: var(--spacing-lg);
    padding: var(--spacing-lg);
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    text-align: center;
    z-index: 1;
    position: relative;
}

.contact-info {
    display: flex;
    justify-content: center;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
    margin-bottom: var(--spacing-md);
}

.contact-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--primary-green);
    text-decoration: none;
    font-size: 0.9rem;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.contact-item:hover {
    background: var(--bg-cream);
    color: var(--primary-green-dark);
    transform: translateY(-2px);
}

.contact-item svg {
    flex-shrink: 0;
}

.footer-tagline {
    font-family: var(--font-display);
    font-size: 0.95rem;
    color: var(--text-medium);
    font-style: italic;
    margin: 0;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    body {
        padding: 0;
    }
    
    .chat-container {
        height: 100vh;
        max-width: 100%;
        border-radius: 0;
    }
    
    .header-text h1 {
        font-size: 1.2rem;
    }
    
    .subtitle {
        font-size: 0.75rem;
    }
    
    .status-text {
        display: none;
    }
    
    .message {
        max-width: 85%;
    }
    
    .contact-footer {
        border-radius: 0;
        margin-top: 0;
    }
    
    .contact-info {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .contact-item {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .logo-icon {
        width: 40px;
        height: 40px;
    }
    
    .logo-icon svg {
        width: 30px;
        height: 30px;
    }
    
    .header-text h1 {
        font-size: 1.1rem;
    }
    
    .message-avatar {
        width: 35px;
        height: 35px;
    }
    
    .message-content {
        font-size: 0.9rem;
        padding: var(--spacing-sm) var(--spacing-md);
    }
}

/* ═══════════════════════════════════════════════════════════════
   UTILIDADES
   ═══════════════════════════════════════════════════════════════ */

.hidden {
    display: none !important;
}

.error-message {
    background: #FEE2E2 !important;
    border: 1px solid #FCA5A5 !important;
    color: #991B1B !important;
}

.success-message {
    background: #D1FAE5 !important;
    border: 1px solid #6EE7B7 !important;
    color: #065F46 !important;
}