/* ==========================================================================
   NeuroIA Edu - Main Stylesheet
   ========================================================================== */

/* --- Variables & Theming --- */
:root {
    /* Color Palette */
    --primary-color: #4f46e5;
    /* Indigo 600 - Technology, Trust */
    --primary-light: #6366f1;
    --primary-dark: #3730a3;

    --secondary-color: #f59e0b;
    /* Amber 500 - Warmth, Energy, Pedagogy */
    --accent-color: #10b981;
    /* Emerald 500 - Success, Growth */

    /* Grays & Neutrals */
    --bg-main: #f8fafc;
    /* Slate 50 */
    --bg-surface: #ffffff;
    --bg-sidebar: #0f172a;
    /* Slate 900 */

    --text-primary-dark: #f8fafc;
    --text-secondary-dark: #94a3b8;

    --text-primary-light: #0f172a;
    --text-secondary-light: #475569;
    --text-muted: #94a3b8;

    /* Layout */
    --sidebar-width: 280px;
    --header-height: 70px;

    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;

    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

/* --- Base Reset & Typography --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary-light);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

h1 {
    font-size: 1.5rem;
}

h2 {
    font-size: 1.25rem;
}

a {
    text-decoration: none;
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    background: none;
}

/* --- Layout Structure --- */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    /* Imagen de fondo del cerebro y gradientes animados para simular un pulso neural */
    background-image:
        linear-gradient(45deg, rgba(15, 23, 42, 0.45) 0%, rgba(99, 102, 241, 0.35) 50%, rgba(15, 23, 42, 0.70) 100%),
        url('sidebar-bg.png');
    background-size: 300% 300%, cover;
    background-position: 0% 50%, center;
    background-blend-mode: overlay, normal;
    animation: neuralPulse 12s ease-in-out infinite;
    color: var(--text-primary-dark);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform var(--transition-normal);
    z-index: 100;
}

@keyframes neuralPulse {
    0% {
        background-position: 0% 50%, center;
    }

    50% {
        background-position: 100% 50%, center;
    }

    100% {
        background-position: 0% 50%, center;
    }
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

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

.logo-icon {
    font-size: 1.5rem;
    color: var(--primary-light);
    filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.5));
}

.logo h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin: 0;
}

.sidebar-nav {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.sidebar-nav ul {
    list-style: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1.5rem;
    color: rgba(255, 255, 255, 0.85);
    /* Más brillante que el anterior text-secondary-dark */
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
    /* Sombra dura para contrastar con las neuronas brillantes */
    cursor: pointer;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
    margin: 0.25rem 0.75rem;
    border-radius: 0.5rem;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.4), 0 2px 4px rgba(0, 0, 0, 0.9);
}

.nav-item.active {
    background-color: rgba(79, 70, 229, 0.2);
    /* Primary color low opacity */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #ffffff;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(99, 102, 241, 0.8), 0 2px 4px rgba(0, 0, 0, 0.9);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.nav-item.active i {
    color: var(--primary-light);
    filter: drop-shadow(0 0 6px rgba(99, 102, 241, 0.8));
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.user-profile-mini {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-light);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary-dark);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary-dark);
}

/* --- Main Content --- */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Header */
.top-header {
    height: var(--header-height);
    background-color: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-menu-btn {
    display: none;
    font-size: 1.25rem;
    color: var(--text-secondary-light);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-icon {
    font-size: 1.25rem;
    color: var(--text-secondary-light);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}

.btn-icon:hover {
    background-color: var(--bg-main);
    color: var(--primary-color);
}

/* Buttons */
.btn-primary {
    background-color: var(--primary-color);
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    background-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.4);
}

/* Body Area */
.content-body {
    flex-grow: 1;
    padding: 2rem;
    overflow-y: auto;
    background-color: var(--bg-main);
}

/* --- Modules Display --- */
/* By default, sections are hidden. Only sections with 'active' class inside module-view are shown */
body .module-view {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}

body .module-view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- UI Components (Cards, Forms etc.) --- */
.card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
    border: 1px solid #e2e8f0;
}

.glow {
    position: relative;
    overflow: hidden;
}

.glow::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(79, 70, 229, 0.05) 0%, transparent 60%);
    z-index: 0;
}

.card-content {
    position: relative;
    z-index: 1;
}

.welcome-card h2 {
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.welcome-card p {
    color: var(--text-secondary-light);
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.card-header {
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.card-header h3 {
    font-size: 1.1rem;
    color: var(--text-primary-light);
}

.list-group {
    list-style: none;
}

.list-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary-light);
}

.list-item:last-child {
    border-bottom: none;
}

.badge {
    background-color: #f1f5f9;
    color: var(--text-secondary-light);
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    font-weight: 500;
}

.badge.highlight {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--secondary-color);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.stat-box {
    background: rgba(79, 70, 229, 0.03);
    border: 1px solid rgba(79, 70, 229, 0.1);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Forms */
.textarea-input {
    width: 100%;
    min-height: 150px;
    padding: 1rem;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary-light);
    resize: vertical;
    transition: border-color var(--transition-fast);
    margin-top: 1rem;
}

.textarea-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 1rem;
}

.w-full {
    width: 100%;
    justify-content: center;
}

.text-sm {
    font-size: 0.875rem;
}

.text-primary {
    color: var(--primary-color);
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 1rem;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary-light);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    color: var(--primary-light);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-out forwards;
}

.tab-content.active {
    display: block;
}

/* File Upload Area */
.file-drop-area {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-md);
    padding: 2.5rem 1rem;
    text-align: center;
    background-color: #f8fafc;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.file-drop-area:hover,
.file-drop-area.dragover {
    border-color: var(--primary-light);
    background-color: rgba(99, 102, 241, 0.05);
}

.file-drop-area i {
    font-size: 2.5rem;
    color: var(--text-secondary-light);
    margin-bottom: 1rem;
    transition: color var(--transition-fast);
}

.file-drop-area:hover i {
    color: var(--primary-light);
}

.file-drop-area p {
    font-weight: 500;
    color: var(--text-primary-light);
    margin-bottom: 0.5rem;
}

.file-info {
    font-size: 0.8rem;
    color: var(--text-secondary-light);
}

.file-input-hidden {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.remove-file-btn {
    color: #ef4444;
    /* red-500 */
    margin-left: 0.5rem;
    font-size: 0.875rem;
}

/* Alerts / Results */
.alert {
    padding: 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.alert-warning {
    background-color: #fffbeb;
    /* amber-50 */
    border: 1px solid #fcd34d;
    /* amber-300 */
    color: #92400e;
    /* amber-900 */
}

.alert h4 {
    color: #b45309;
    /* amber-700 */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.quote {
    font-style: italic;
    background: rgba(255, 255, 255, 0.5);
    padding: 0.75rem;
    border-left: 3px solid #fbbf24;
    /* amber-400 */
    margin-bottom: 1rem;
    border-radius: 0 4px 4px 0;
}

.alert hr {
    border: 0;
    height: 1px;
    background: rgba(245, 158, 11, 0.2);
    margin: 1rem 0;
}

/* --- Form Utilities --- */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.col-span-2 {
    grid-column: span 2 / span 2;
}

.gap-4 {
    gap: 1rem;
}

.form-input {
    padding: 0.75rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary-light);
    transition: all var(--transition-fast);
    background-color: white;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.min-h-20 {
    min-height: 5rem;
}

/* Toggles */
.toggle {
    width: 3.25rem;
    height: 1.75rem;
    background-color: #cbd5e1;
    border-radius: 9999px;
    position: relative;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 1.5rem;
    height: 1.5rem;
    background-color: white;
    border-radius: 50%;
    transition: transform var(--transition-fast);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.toggle.active {
    background-color: var(--primary-light);
}

.toggle.active::after {
    transform: translateX(1.5rem);
}

/* --- Timeline components --- */
.timeline-container {
    padding-left: 2rem;
}

.timeline-item {
    margin-bottom: 1.5rem;
}

.timeline-icon {
    top: -4px;
}

.alert h5 {
    color: #92400e;
    margin-bottom: 0.25rem;
}

.alert p {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}

.alert p:last-child {
    margin-bottom: 0;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.btn-outline:hover {
    background: rgba(79, 70, 229, 0.05);
}

/* --- Premium Utilities (Tailwind Ports) --- */
.text-gradient {
    background: linear-gradient(135deg, var(--primary-color) 0%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
    display: inline-block;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: var(--text-muted);
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-secondary-light);
}

.bg-gradient-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* =========================================
   Interactive SdA Highlights (Tooltips)
   ========================================= */

.neuro-highlight {
    position: relative;
    display: inline-block;
    cursor: help;
    font-weight: 600;
    padding: 0 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

/* Tooltip Base (Hidden) */
.neuro-highlight::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background-color: #1e293b;
    /* slate-800 */
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;

    /* FIX: Allow wrapping and limit width to prevent clipping */
    white-space: normal;
    width: max-content;
    max-width: 250px;
    text-align: center;
    line-height: 1.3;

    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 150;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    pointer-events: none;
}

/* Tooltip Arrow (Hidden) */
.neuro-highlight::after {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    border-width: 5px;
    border-style: solid;
    border-color: #1e293b transparent transparent transparent;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 50;
    pointer-events: none;
}

/* Show Tooltip on Hover */
.neuro-highlight:hover::before,
.neuro-highlight:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Support Colors (Emerald Theme) */
.support-hl {
    background-color: #d1fae5;
    /* emerald-100 */
    color: #047857;
    /* emerald-700 */
    border-bottom: 2px dashed #34d399;
    /* emerald-400 */
}

.support-hl:hover {
    background-color: #a7f3d0;
    /* emerald-200 */
}

/* Executive Function Colors (Violet Theme) */
.ef-hl {
    background-color: #ede9fe;
    /* violet-100 */
    color: #6d28d9;
    /* violet-700 */
    border-bottom: 2px dashed #a78bfa;
    /* violet-400 */
}

.ef-hl:hover {
    background-color: #ddd6fe;
    /* violet-200 */
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .mobile-menu-btn {
        display: block;
    }
}

/* --- Adjustment Rows & iOS Style Toggles --- */
.adjustment-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background-color: #ffffff;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    margin-bottom: 1rem;
}

.adjustment-row .flex {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.adjustment-row .text-rose-500 {
    color: #f43f5e;
}

.adjustment-row .text-indigo-500 {
    color: #6366f1;
}

.adjustment-row .text-emerald-500 {
    color: #10b981;
}

/* Fix Button Generate SdA */
.btn-generate-sda {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 12px;
    font-size: 1.125rem;
    font-weight: 700;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Vector Transversal Badges / Buttons */
.vector-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    color: #475569;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.vector-btn:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

.vector-btn.active {
    background-color: var(--primary-light);
    color: #ffffff;
    border-color: var(--primary-light);
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}

.vector-btn.active i {
    color: #ffffff;
}