/**
 * ============================================================================
 * EduAI Studio - Sistema de Diseño Minimalista, Moderno y Responsive
 * ============================================================================
 */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --primary-subtle: #eff6ff;
    --secondary: #475569;
    --accent: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-trans: rgba(255, 255, 255, 0.85);
    --bg-hover: #f1f5f9;
    --bg-active: #e2e8f0;

    --border-color: #e2e8f0;
    --border-subtle: #f1f5f9;

    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;
    --text-inverse: #ffffff;

    --font-heading: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

    --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    --sidebar-width: 270px;
}

body.theme-dark {
    --bg-main: #090d16;
    --bg-surface: #111827;
    --bg-surface-trans: rgba(17, 24, 39, 0.85);
    --bg-hover: #1f2937;
    --bg-active: #374151;

    --border-color: #1f2937;
    --border-subtle: #192231;

    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --text-subtle: #6b7280;

    --primary-subtle: rgba(37, 99, 235, 0.15);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* --------------------------------------------------------------------------
   Reset & Tipografía Base
-------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    background-color: var(--bg-main);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--text-main);
    font-weight: 700;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* --------------------------------------------------------------------------
   Componentes de Botones y Formularios
-------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.15rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    user-select: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-outline {
    background: var(--bg-surface);
    color: var(--text-main);
    border-color: var(--border-color);
}
.btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.btn-danger {
    background: #fee2e2;
    color: var(--danger);
    border-color: transparent;
}
.btn-danger:hover {
    background: var(--danger);
    color: #ffffff;
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-label {
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-input {
    width: 100%;
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: var(--text-main);
    transition: var(--transition);
    outline: none;
}
.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea.form-input {
    resize: vertical;
    min-height: 80px;
}

/* --------------------------------------------------------------------------
   Estructura Principal de la Aplicación (App Shell)
-------------------------------------------------------------------------- */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: var(--transition);
    z-index: 50;
}

.sidebar-header {
    padding: 1.25rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #ffffff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}
.brand-name {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.925rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    background: transparent;
    text-align: left;
    width: 100%;
}
.nav-item i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}
.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}
.nav-item.active {
    background: var(--primary-subtle);
    color: var(--primary);
    font-weight: 600;
}
.nav-item.active i {
    color: var(--primary);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    background: var(--bg-hover);
    cursor: pointer;
}
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}
.user-info {
    flex: 1;
    overflow: hidden;
}
.user-name {
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
.user-role-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Contenido Principal y Barra Superior */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

.app-topbar {
    height: 64px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.mobile-toggle {
    display: none;
    font-size: 1.25rem;
    background: transparent;
    border: none;
    color: var(--text-main);
    cursor: pointer;
}
.view-title {
    font-size: 1.2rem;
    font-weight: 700;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.view-container {
    flex: 1;
    overflow-y: auto;
    position: relative;
    display: none;
}
.view-container.active {
    display: flex;
    flex-direction: column;
}

/* --------------------------------------------------------------------------
   MÓDULO 1: CHAT CON IA (GPT-6 Luna)
-------------------------------------------------------------------------- */
.chat-layout {
    display: flex;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

.chat-history-sidebar {
    width: 250px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.chat-history-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-subtle);
}
.chat-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.conv-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: var(--transition);
}
.conv-item:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}
.conv-item.active {
    background: var(--primary-subtle);
    color: var(--primary);
    font-weight: 600;
}
.conv-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.chat-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-main);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.message-bubble {
    display: flex;
    gap: 1rem;
    max-width: 820px;
    margin: 0 auto;
    width: 100%;
}
.message-bubble.user {
    flex-direction: row-reverse;
}
.msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}
.message-bubble.user .msg-avatar {
    background: var(--primary);
    color: #fff;
}
.message-bubble.assistant .msg-avatar {
    background: linear-gradient(135deg, var(--accent), var(--primary));
    color: #fff;
}
.msg-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    line-height: 1.6;
    font-size: 0.95rem;
    position: relative;
}
.message-bubble.user .msg-content {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    border-bottom-right-radius: var(--radius-sm);
}
.message-bubble.assistant .msg-content {
    border-bottom-left-radius: var(--radius-sm);
}

/* Prompt Chips para Docentes y Estudiantes */
.prompt-chips-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 1.5rem;
    overflow-x: auto;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
}
.prompt-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font-size: 0.775rem;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
}
.prompt-chip:hover {
    background: var(--primary-subtle);
    color: var(--primary);
    border-color: var(--primary);
}

.chat-input-bar {
    padding: 1rem 1.5rem;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
}
.chat-input-form {
    max-width: 820px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.5rem 0.75rem;
    transition: var(--transition);
}
.chat-input-form:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.chat-textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-size: 0.95rem;
    resize: none;
    max-height: 160px;
    min-height: 24px;
    padding: 0.35rem 0;
}

/* --------------------------------------------------------------------------
   MÓDULO 2: GENERADOR DE IMÁGENES (Sunburst / Flare)
-------------------------------------------------------------------------- */
.generator-layout {
    max-width: 1040px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
}

.model-selector-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.model-card-option {
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    background: var(--bg-surface);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}
.model-card-option:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
}
.model-card-option.active {
    border-color: var(--primary);
    background: var(--primary-subtle);
}
.model-badge-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--primary);
}
.model-card-option.active .model-badge-icon {
    background: var(--primary);
    color: #ffffff;
}

.pill-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.pill-option {
    padding: 0.45rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    font-size: 0.825rem;
    cursor: pointer;
    transition: var(--transition);
}
.pill-option.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.image-preview-stage {
    margin-top: 2rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    min-height: 380px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}
.image-preview-stage img {
    max-width: 100%;
    max-height: 520px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

/* --------------------------------------------------------------------------
   MÓDULO 3 & 5: GENERADOR Y EDITOR DE DIAPOSITIVAS (PRESENTACIONES)
-------------------------------------------------------------------------- */
.slides-layout {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
}

.deck-viewer-container {
    margin-top: 2rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
}

.slide-canvas {
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-lg);
    padding: 3rem 4rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

/* Temas Visuales de Diapositivas */
.slide-canvas.theme-minimal-light {
    background: #ffffff;
    color: #0f172a;
    border: 1px solid #e2e8f0;
}
.slide-canvas.theme-ocean-academic {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    color: #ffffff;
}
.slide-canvas.theme-emerald-modern {
    background: linear-gradient(135deg, #064e3b 0%, #065f46 100%);
    color: #ffffff;
}
.slide-canvas.theme-midnight-pro {
    background: linear-gradient(135deg, #18181b 0%, #27272a 100%);
    color: #ffffff;
}

.slide-title-display {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 1.5rem;
}
.slide-bullets-display {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    font-size: 1.15rem;
}
.slide-bullets-display li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}
.slide-bullets-display li::before {
    content: "•";
    color: var(--primary);
    font-size: 1.5rem;
    line-height: 1;
}
.theme-ocean-academic .slide-bullets-display li::before,
.theme-emerald-modern .slide-bullets-display li::before,
.theme-midnight-pro .slide-bullets-display li::before {
    color: #60a5fa;
}

.slide-footer-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    opacity: 0.75;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 1rem;
}
.theme-minimal-light .slide-footer-meta {
    border-top-color: #e2e8f0;
}

/* --------------------------------------------------------------------------
   MÓDULO 4: GALERÍA DE IMÁGENES
-------------------------------------------------------------------------- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
}
.gallery-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    position: relative;
    display: flex;
    flex-direction: column;
}
.gallery-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}
.gallery-thumb-wrapper {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    position: relative;
    background: var(--bg-hover);
    cursor: pointer;
}
.gallery-thumb-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.gallery-card:hover .gallery-thumb-wrapper img {
    transform: scale(1.04);
}

.gallery-info {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}
.gallery-prompt {
    font-size: 0.85rem;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}
.gallery-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: auto;
}

/* --------------------------------------------------------------------------
   Modales & Overlays (Lightbox, Diapositivas Fullscreen, Auth)
-------------------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.5rem;
}
.modal-overlay.active {
    display: flex;
}
.modal-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 540px;
    padding: 2rem;
    box-shadow: var(--shadow-xl);
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    animation: toastIn 0.25s ease forwards;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.info    { border-left: 4px solid var(--primary); }

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

/* --------------------------------------------------------------------------
   Responsive Design (Mobile & Tablets)
-------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .app-sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        box-shadow: var(--shadow-xl);
    }
    .app-sidebar.open {
        left: 0;
    }
    .mobile-toggle {
        display: block;
    }
    .chat-history-sidebar {
        display: none;
    }
    .model-selector-grid {
        grid-template-columns: 1fr;
    }
}
