/*!
 * =============================================================================
 * index.css - Estilos principales para Mart-E SPA
 * =============================================================================
 * @version 2.0.0
 * @author Mart-E Team
 * @description Diseño pastel, accesible (AAA), responsivo y moderno.
 *              Personalizable mediante variables CSS en :root.
 * =============================================================================
 */

/* =============================================================================
   VARIABLES CSS (TEMA PASTEL - PERSONALIZABLE)
   ============================================================================= */
:root {
    /* Paleta de colores principal (pastel) */
    --primary: #6C8EBF;        /* Azul pastel suave */
    --primary-dark: #5A7AAD;   /* Azul más profundo para hover */
    --secondary: #F4A261;      /* Naranja cálido pastel */
    --secondary-dark: #E08E4A; /* Naranja para hover */
    --accent: #6A9C89;         /* Verde menta pastel */
    --accent-dark: #54836E;    /* Verde para hover */
    --bg-body: #F9F7F3;        /* Crema claro (fondo general) */
    --bg-card: #FFFFFF;        /* Blanco para tarjetas */
    --bg-alt: #F0F2F5;         /* Fondo alternativo (footer, etc.) */
    --text-dark: #2D3E50;      /* Texto principal (alto contraste) */
    --text-soft: #5A6C7D;      /* Texto secundario */
    --text-light: #FFFFFF;     /* Texto sobre fondos oscuros */
    --border-light: #E2E8F0;   /* Bordes suaves */
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.1);
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --transition: all 0.25s ease;
}

/* =============================================================================
   RESET Y ESTILOS BASE
   ============================================================================= */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-dark);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Skip link para accesibilidad */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: var(--text-light);
    padding: 8px 16px;
    text-decoration: none;
    z-index: 1000;
    border-radius: 0 0 var(--radius-sm) 0;
    font-weight: 500;
}
.skip-link:focus {
    top: 0;
    outline: 2px solid var(--primary-dark);
}

/* Contenedor principal */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* =============================================================================
   HEADER Y NAVEGACIÓN
   ============================================================================= */
.site-header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 500;
    border-bottom: 1px solid var(--border-light);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 0.8rem 1.5rem;
}

.logo {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.logo-link {
    font-size: 1.8rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--primary);
    letter-spacing: -0.02em;
    transition: var(--transition);
}
.logo-link:hover {
    color: var(--primary-dark);
}

.tagline {
    font-size: 0.85rem;
    color: var(--text-soft);
    font-weight: 400;
    font-style: italic;
}

.main-nav ul {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.main-nav a {
    text-decoration: none;
    font-weight: 500;
    color: var(--text-dark);
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
}
.main-nav a:hover,
.main-nav a:focus-visible {
    border-bottom-color: var(--secondary);
    color: var(--primary);
}
.main-nav a.active {
    border-bottom-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.lang-selector {
    display: flex;
    gap: 0.5rem;
    font-size: 0.9rem;
}
.lang-option {
    text-decoration: none;
    font-weight: 600;
    color: var(--text-soft);
    padding: 0.25rem 0.75rem;
    border-radius: 30px;
    transition: var(--transition);
}
.lang-option.active {
    background: var(--primary);
    color: white;
}
.lang-option:hover {
    background: var(--border-light);
    color: var(--text-dark);
}

.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border-light);
    font-size: 1.8rem;
    padding: 0.25rem 0.8rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-dark);
    transition: var(--transition);
}
.mobile-menu-toggle:hover {
    background: var(--border-light);
}

/* =============================================================================
   MAIN Y VISTAS
   ============================================================================= */
.site-main {
    flex: 1;
    padding: 3rem 0;
}

.view-container {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =============================================================================
   TIPOGRAFÍA
   ============================================================================= */
h1, h2, h3, h4 {
    line-height: 1.3;
    font-weight: 700;
}
h1 {
    font-size: 3.2rem;
    margin-bottom: 1rem;
    color: var(--primary);
}
h2 {
    font-size: 2.4rem;
    margin-bottom: 1.8rem;
    border-left: 6px solid var(--secondary);
    padding-left: 1.5rem;
}
h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--primary-dark);
}
p {
    margin-bottom: 1rem;
}

/* =============================================================================
   COMPONENTES REUTILIZABLES
   ============================================================================= */
.btn {
    display: inline-block;
    background: var(--primary);
    color: var(--text-light);
    font-weight: 600;
    padding: 0.75rem 1.8rem;
    border-radius: 40px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    text-align: center;
}
.btn:hover,
.btn:focus-visible {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    outline: 2px solid var(--primary-dark);
    outline-offset: 2px;
}
.btn-secondary {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}
.btn-secondary:hover {
    background: var(--border-light);
    color: var(--primary-dark);
    border-color: var(--primary-dark);
}
.btn-small {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 1.8rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    transition: var(--transition);
}
.card:hover {
    box-shadow: var(--shadow-lg);
}

/* Formularios */
.form-group {
    margin-bottom: 1.5rem;
}
label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}
input, textarea, select {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg-card);
    transition: var(--transition);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 142, 191, 0.2);
}
.form-feedback {
    margin-top: 1rem;
    font-size: 0.9rem;
}

/* Utilidades */
.text-center { text-align: center; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 2rem; }

/* =============================================================================
   VISTA HOME
   ============================================================================= */
.hero {
    background: linear-gradient(145deg, #FFFFFF 0%, #F0F4FA 100%);
    text-align: center;
    margin-bottom: 2rem;
}
.hero-subtitle {
    font-size: 1.3rem;
    color: var(--text-soft);
    max-width: 700px;
    margin: 0 auto 1.5rem;
}
.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin: 2.5rem 0;
}
.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    text-align: center;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: var(--transition);
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}
.feature-card {
    transition: var(--transition);
}
.feature-card:hover {
    transform: translateY(-5px);
}
.feature-card h3 {
    margin-bottom: 0.5rem;
}

/* =============================================================================
   VISTA DOCS Y DEMO (SIMULADOR DE CHAT)
   ============================================================================= */
.code-block {
    background: #1e293b;
    color: #e2e8f0;
    font-family: monospace;
    overflow-x: auto;
    margin: 1.5rem 0;
}
.code-block pre {
    margin: 0;
}
.code-block code {
    font-size: 0.9rem;
}

.steps-list {
    margin: 1.5rem 0;
    padding-left: 1.8rem;
}
.steps-list li {
    margin-bottom: 0.5rem;
}

.api-simulator {
    margin: 2rem 0;
}
.chat-window {
    background: #F5F7FA;
    border-radius: var(--radius-sm);
    padding: 1.2rem;
    min-height: 280px;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 1rem;
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.message {
    padding: 0.75rem 1.2rem;
    border-radius: 20px;
    max-width: 85%;
    word-wrap: break-word;
    animation: messageSlide 0.2s ease;
}
@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.message.user {
    background: var(--primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.message.bot {
    background: white;
    border: 1px solid var(--border-light);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.chat-input {
    display: flex;
    gap: 0.75rem;
}
.chat-input input {
    flex: 1;
}

/* =============================================================================
   VISTA CONTACTO
   ============================================================================= */
.contact-view form {
    max-width: 700px;
    margin: 0 auto;
}

/* =============================================================================
   VISTA LOGIN
   ============================================================================= */
.login-container {
    max-width: 450px;
    margin: 2rem auto;
}

/* =============================================================================
   VISTA ADMIN (PANEL + GRÁFICAS)
   ============================================================================= */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.admin-stat {
    background: white;
    padding: 1.2rem;
    border-radius: var(--radius-md);
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}
.admin-stat .value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}
.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}
.chart-card {
    background: white;
    border-radius: var(--radius-md);
    padding: 1rem;
}
.messages-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: var(--radius-md);
    overflow-x: auto;
    display: block;
}
.messages-table thead {
    background: var(--primary);
    color: white;
}
.messages-table th,
.messages-table td {
    padding: 0.9rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}
.messages-table th {
    font-weight: 600;
}
.messages-table tr:last-child td {
    border-bottom: none;
}
.mark-read-btn {
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.3rem 0.8rem;
    border-radius: 30px;
    border: none;
    background: var(--secondary);
    color: white;
    transition: var(--transition);
}
.mark-read-btn:hover {
    background: var(--secondary-dark);
}

/* =============================================================================
   WIDGET DE CHAT FLOTANTE (OPCIONAL, PERO INCLUIDO)
   ============================================================================= */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}
.chat-toggle {
    background: var(--primary);
    color: white;
    border: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 28px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-toggle:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}
.chat-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    max-width: calc(100vw - 40px);
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-light);
}
.chat-panel.open {
    display: flex;
    animation: slideUp 0.2s ease;
}
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.chat-header {
    background: var(--primary);
    color: white;
    padding: 0.8rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}
.chat-header button {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
}
.chat-messages {
    height: 300px;
    overflow-y: auto;
    padding: 0.8rem;
    background: var(--bg-body);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.chat-messages .message {
    max-width: 90%;
}
.chat-input-area {
    display: flex;
    padding: 0.8rem;
    gap: 0.5rem;
    border-top: 1px solid var(--border-light);
    background: white;
}
.chat-input-area input {
    flex: 1;
    padding: 0.6rem;
    font-size: 0.9rem;
}
.chat-input-area button {
    background: var(--primary);
    border: none;
    color: white;
    padding: 0 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.chat-input-area button:hover {
    background: var(--primary-dark);
}

/* =============================================================================
   FOOTER
   ============================================================================= */
.site-footer {
    background: var(--primary);
    color: var(--text-light);
    padding: 1.5rem 0;
    margin-top: 2rem;
}
.footer-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.footer-small {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* =============================================================================
   RESPONSIVE (MÓVIL Y TABLET)
   ============================================================================= */
@media (max-width: 768px) {
    h1 { font-size: 2.2rem; }
    h2 { font-size: 1.8rem; }
    .header-container {
        flex-wrap: wrap;
        position: relative;
    }
    .main-nav {
        order: 3;
        width: 100%;
        display: none;
    }
    .main-nav.active {
        display: block;
    }
    .main-nav ul {
        flex-direction: column;
        gap: 0.5rem;
        padding: 1rem 0;
        background: var(--bg-card);
        border-radius: var(--radius-md);
        margin-top: 0.5rem;
    }
    .mobile-menu-toggle {
        display: block;
    }
    .lang-selector {
        margin-left: auto;
        margin-right: 1rem;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .hero-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .btn {
        text-align: center;
    }
    .chat-panel {
        width: 300px;
        right: 0;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 1rem;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .features-grid {
        grid-template-columns: 1fr;
    }
    .admin-stats {
        grid-template-columns: 1fr 1fr;
    }
    .messages-table th,
    .messages-table td {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
}

/* =============================================================================
   ANIMACIONES ADICIONALES
   ============================================================================= */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}
.pulse {
    animation: pulse 1s infinite;
}

/* =============================================================================
   ACCESIBILIDAD: FOCUS VISIBLE
   ============================================================================= */
:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* =============================================================================
   SCROLLBAR PERSONALIZADA (OPCIONAL)
   ============================================================================= */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--border-light);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}