/* ============================================================
   ARTEXA GPT - Estilos Modernos
   ============================================================ */

:root {
    --primary-bg: #ffffff;
    --secondary-bg: #f8f9fa;
    --page-bg: #e6e4e0; /* Warm gray */
    --header-bg: #000000;
    --accent-color: #000000;
    --accent-hover: #333333;
    --text-primary: #1a1a1a;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --text-inverse: #ffffff;
    --bot-bubble: #f1f3f5;
    --user-bubble: #000000;
    --border-color: #e2e8f0;
    --link-color: #2563eb;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--page-bg);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

.container {
    max-width: 100%;
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0;
}

/* ============================================================
   HEADER
   ============================================================ */

.header {
    background: var(--header-bg);
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    box-shadow: var(--shadow);
    z-index: 10;
    color: var(--text-inverse);
    position: relative;
}

.logo {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gpt-text {
    color: #ffffff;
    font-weight: 300;
    font-size: 1.2rem;
    opacity: 0.8;
    letter-spacing: 1px;
    margin-top: 4px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #a0aec0;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--error-color);
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background: var(--success-color);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============================================================
   CHAT CONTAINER
   ============================================================ */

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    background: var(--primary-bg);
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

.chat-container::-webkit-scrollbar {
    width: 8px;
}

.chat-container::-webkit-scrollbar-track {
    background: var(--primary-bg);
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: #4a5568;
}

/* ============================================================
   MENSAJES
   ============================================================ */

.message {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.3s ease-in;
    max-width: 80%;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.bot {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
    background: var(--secondary-bg);
    border: 2px solid var(--border-color);
    overflow: hidden;
}

.message.bot .message-avatar {
    background: #ffffff;
    color: white;
    padding: 5px;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e0 100%);
    color: #1a1a1a;
}

.message-content {
    padding: 1rem 1.25rem;
    border-radius: 16px;
    background: var(--bot-bubble);
    box-shadow: var(--shadow);
    word-wrap: break-word;
}

.message.bot .message-content {
    max-width: 65%;
}

/* Estilo específico para el mensaje de bienvenida */
.message.welcome-message .message-content {
    max-width: 98%;
}

.message.user .message-content {
    background: var(--user-bubble);
    color: var(--text-inverse);
}

.message-content p {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* ============================================================
   IMÁGENES EN CHAT
   ============================================================ */

.message-image {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 12px;
    margin-top: 0.75rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.message-image:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   ENLACES
   ============================================================ */

.message-link {
    display: inline-block;
    color: var(--link-color);
    text-decoration: none;
    font-weight: 600;
    margin-top: 0.5rem;
    transition: color 0.2s;
}

.message-link:hover {
    color: #60a5fa;
    text-decoration: underline;
}

/* ============================================================
   PRODUCTOS
   ============================================================ */

.product-card {
    background: var(--secondary-bg);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1rem;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.product-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.product-sku {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.product-description {
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.product-price {
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--border-color);
}

.product-price strong {
    color: var(--accent-color);
}

/* ============================================================
   INDICADORES DE ACTIVIDAD
   ============================================================ */

.activity-message {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #00d9ff;
    font-style: italic;
    padding: 0.75rem 1rem;
    background: rgba(0, 217, 255, 0.1);
    border-radius: 8px;
    border-left: 3px solid #00d9ff;
    margin-bottom: 1rem;
    animation: fadeIn 0.3s ease-in;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--warning-color);
    font-style: italic;
    padding: 0.75rem 1rem;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.typing-indicator .dots {
    display: flex;
    gap: 4px;
}

.typing-indicator .dots span {
    width: 6px;
    height: 6px;
    background: var(--warning-color);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator .dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator .dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ============================================================
   INPUT AREA
   ============================================================ */

.input-area {
    background: var(--secondary-bg);
    padding: 1.5rem 2rem;
    border-top: 2px solid var(--border-color);
    box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.05);
    position: relative;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 0.75rem;
}

/* Preview de imagen (estilo Gemini) */
.image-preview-container {
    display: none;
    margin-bottom: 1rem;
    position: relative;
    width: fit-content;
}

.image-preview-container.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

.image-preview {
    max-height: 120px;
    border-radius: 12px;
    border: 2px solid var(--accent-color);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.remove-image-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: transform 0.2s;
}

.remove-image-btn:hover {
    transform: scale(1.1);
}

.upload-button {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
    width: 48px;
    height: 48px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.upload-button:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: rgba(20, 86, 184, 0.1);
}

.message-input {
    flex: 1;
    background: var(--primary-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 0.875rem 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    transition: border-color 0.3s;
}

.message-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.message-input::placeholder {
    color: var(--text-muted);
}

.send-button {
    background: var(--accent-color);
    border: none;
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s, transform 0.2s;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.send-button:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    opacity: 0.5;
}

.disclaimer {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.terms-link {
    color: var(--link-color);
    text-decoration: none;
    font-weight: 600;
}

.terms-link:hover {
    text-decoration: underline;
}

/* ============================================================
   LOADING INDICATOR
   ============================================================ */

.loading-indicator {
    position: fixed;
    bottom: 200px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--secondary-bg);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    gap: 1rem;
    z-index: 20;
}

.loading-indicator.active {
    display: flex;
}

.loading-dots {
    display: flex;
    gap: 6px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--accent-color);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* ============================================================
   MODAL DE IMAGEN
   ============================================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.6);
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 40px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--accent-color);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    .header {
        padding: 1rem;
        flex-direction: column;
        gap: 0.75rem;
        align-items: center;
        justify-content: center;
    }

    .logo {
        position: static;
        transform: none;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    .chat-container {
        padding: 1rem;
    }

    .message-content {
        max-width: 85%;
    }

    .input-area {
        padding: 1rem;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
}
