/* ==========================================================================
   1. RESET GLOBAL Y VARIABLES DINÁMICAS
   ========================================================================== */
:root {
    --primary-color: #2563eb;
    --text-main: #1f2937;
    --text-muted: #4b5563;
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --border-color: #e5e7eb;
    --sidebar-bg: #ffffff;
}

*, *::before, *::after { box-sizing: border-box; }

body { 
    margin: 0; 
    padding: 0; 
    font-family: var(--tenant-font, system-ui, -apple-system, sans-serif); 
    background-color: var(--bg-body); 
    color: var(--text-main); 
    display: flex; 
    flex-direction: column; 
    min-height: 100vh; 
}

/* ==========================================================================
   2. BOTONES Y UTILIDADES GENÉRICAS
   ========================================================================== */
.btn-primary { 
    background-color: var(--primary-color, #2563eb); 
    color: white !important; 
    padding: 0.75rem 1.2rem; 
    border: none; 
    border-radius: 6px; 
    font-size: 1rem; 
    font-weight: 600; 
    cursor: pointer; 
    text-decoration: none;
    transition: all 0.2s; 
    display: inline-block;
}
.btn-primary:hover { filter: brightness(0.9); transform: translateY(-1px); }

.btn-danger { background-color: #dc2626; color: white !important; padding: 0.5rem 1.2rem; border-radius: 6px; }

/* Utilidades Textos */
.text-danger { color: #dc2626; font-size: 0.85rem; margin-top: 0.35rem; display: block; }
.invalid-feedback { color: #dc3545; font-size: 0.85rem; margin-top: 0.4rem; display: block; }
.is-invalid { border-color: #dc3545 !important; }

/* Utilidades para Autenticación */
.auth-footer { text-align: center; margin-top: 1.5rem; font-size: 0.9rem; color: var(--text-muted); }
.auth-footer a { color: var(--primary-color); font-weight: 500; text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }
.auth-footer a.text-muted { color: var(--text-muted); }
.form-help-text { color: #64748b; font-size: 0.8rem; display: block; margin-top: 0.3rem; }
.auth-icon-header { text-align: center; margin-bottom: 1rem; color: var(--primary-color); display: flex; justify-content: center; }

/* ==========================================================================
   3. NAVEGACIÓN Y NAVBAR (Pública y Campus)
   ========================================================================== */
.navbar { 
    display: flex; justify-content: space-between; align-items: center; 
    padding: 1rem 5%; background-color: var(--sidebar-bg, #ffffff); 
    box-shadow: 0 2px 10px rgba(0,0,0,0.05); position: sticky; top: 0; z-index: 1000; width: 100%; 
}

.brand-logo, .brand img { max-height: 50px; width: auto; }
.brand-text, .brand h2 { font-size: 1.5rem; font-weight: bold; color: var(--primary-color); text-decoration: none; margin: 0; }

.nav-links { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }
.nav-item, .nav-links a { text-decoration: none; color: var(--text-main, #334155); font-weight: 500; font-size: 1rem; transition: color 0.2s ease; }
.nav-item:hover, .nav-links a:hover { color: var(--primary-color, #2563eb); }
.nav-divider { width: 1px; height: 20px; background-color: #cbd5e1; margin: 0 0.5rem; }
.btn-logout { color: #dc2626 !important; font-weight: 600 !important; }

/* Botón Hamburguesa */
.mobile-menu-btn, .hamburger { display: none; background: none; border: none; cursor: pointer; padding: 0.5rem; flex-direction: column; gap: 5px; }
.mobile-menu-btn span { display: block; width: 25px; height: 3px; background-color: var(--text-main); border-radius: 3px; transition: all 0.3s ease-in-out; }

@media (max-width: 768px) {
    .mobile-menu-btn, .hamburger { display: flex; }
    .nav-links { position: absolute; top: 100%; left: 0; width: 100%; background-color: #ffffff; flex-direction: column; align-items: stretch; padding: 0; max-height: 0; overflow: hidden; transition: max-height 0.3s ease-in-out; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
    .nav-links.active { max-height: 400px; padding: 1rem 0; }
    .nav-item { padding: 1rem 2rem; text-align: center; border-bottom: 1px solid #f1f5f9; }
    .mobile-menu-btn.open span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
    .mobile-menu-btn.open span:nth-child(2) { opacity: 0; }
    .mobile-menu-btn.open span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }
}

/* ==========================================================================
   4. FORMULARIOS GLOBALES Y AUTENTICACIÓN
   ========================================================================== */
.form-group { margin-bottom: 1.5rem; }
.form-label { display: block; margin-bottom: 0.5rem; font-weight: 600; color: #475569; font-size: 0.9rem; }
.form-label-flex { display: flex; justify-content: space-between; align-items: center; }

.form-control, .form-input { width: 100%; padding: 0.75rem 1rem; border: 1px solid var(--border-color, #cbd5e1); border-radius: 8px; font-size: 1rem; box-sizing: border-box; transition: all 0.2s; outline: none; }
.form-control:focus, .form-input:focus { border-color: var(--primary-color, #2563eb); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.col { flex: 1; min-width: 200px; }

/* Tarjetas de Login/Registro */
.auth-card { width: 100%; max-width: 400px; margin: 4rem auto; padding: 2.5rem; background: var(--bg-card, #ffffff); border-radius: 10px; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); }
.auth-title { text-align: center; margin-bottom: 0.5rem; font-size: 1.5rem; font-weight: 700; color: var(--text-main, #334155); }
.auth-subtitle { text-align: center; color: var(--text-muted, #64748b); margin-bottom: 2rem; font-size: 0.9rem; line-height: 1.4; }
.link-forgot { color: var(--primary-color, #2563eb); text-decoration: none; font-size: 0.85rem; font-weight: 500; }
.link-forgot:hover { text-decoration: underline; }

/* Alertas Globales */
.alert-error, .alert-danger { background-color: #fee2e2; color: #991b1b; padding: 1rem; border-radius: 8px; margin-bottom: 1.5rem; border: 1px solid #f87171; font-size: 0.9rem; text-align: center; }
.alert-success { background-color: #dcfce7; color: #166534; padding: 1rem; border-radius: 8px; margin-bottom: 1.5rem; border: 1px solid #86efac; font-size: 0.9rem; text-align: center; }

/* ==========================================================================
   6. UTILIDADES DE LAYOUT Y COMPONENTES (CERO ESTILOS EN LÍNEA)
   ========================================================================== */
/* Menús e Iconos */
.nav-item, .btn-logout { display: flex; align-items: center; gap: 0.4rem; }

/* Contenedor del Campus */
.campus-main { padding-top: 2rem; padding-bottom: 4rem; max-width: 1200px; margin: 0 auto; width: 100%; box-sizing: border-box; }

/* Footer Global */
.app-footer { text-align: center; padding: 2rem 1rem; border-top: 1px solid var(--border-color); color: var(--text-muted); font-size: 0.9rem; margin-top: auto; background-color: transparent; }
.footer-brand { font-weight: bold; color: var(--primary-color); }

/* Alertas Centradas con Icono */
.alert-centered { max-width: 1000px; margin: 0 auto 2rem auto; display: flex; align-items: center; justify-content: center; gap: 0.5rem; font-weight: bold; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }

/* Tarjetas de Cursos (Landing/Campus) */
.course-card { padding: 0; display: flex; flex-direction: column; overflow: hidden; text-align: left; background: var(--bg-card); border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
.course-image { height: 200px; background-color: #f1f5f9; background-size: cover; background-position: center; border-bottom: 1px solid var(--border-color); }
.course-card-body { padding: 1.5rem; flex-grow: 1; display: flex; flex-direction: column; }
.course-header-flex { display: flex; justify-content: space-between; align-items: start; margin-bottom: 1rem; gap: 10px; }
.course-badge { background: #e0f2fe; color: #0284c7; padding: 0.25rem 0.75rem; border-radius: 999px; font-size: 0.75rem; font-weight: bold; white-space: nowrap; display: flex; align-items: center; gap: 0.25rem; }
.course-topics-list { list-style-type: none; padding: 0; margin: 0; }
.course-topic-item { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 0.35rem; display: flex; align-items: center; gap: 0.35rem; }
.course-footer { margin-top: auto; border-top: 1px solid var(--border-color); padding-top: 1.25rem; text-align: center; }
.btn-course-action { display: flex; align-items: center; justify-content: center; gap: 0.5rem; width: 100%; font-size: 0.9rem; }

/* ==========================================================================
   7. COMPONENTES DE PERFIL Y TARJETAS (CERO ESTILOS EN LÍNEA)
   ========================================================================== */
.account-wrapper { max-width: 900px; margin: 2rem auto; padding: 0 1.5rem; }

.profile-hero { text-align: center; margin-bottom: 2rem; }
.profile-avatar-circle { width: 80px; height: 80px; background: var(--primary-color, #2563eb); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 2.5rem; margin: 0 auto 1rem auto; font-weight: bold; }
.profile-hero-name { margin: 0 0 0.5rem 0; color: #0f172a; }
.role-pill { background: #e2e8f0; color: #475569; padding: 0.25rem 0.75rem; border-radius: 999px; font-size: 0.85rem; font-weight: 600; display: inline-block; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 2rem; }
.card-panel { background: white; border-radius: 12px; padding: 2rem; box-shadow: 0 4px 6px rgba(0,0,0,0.05); border: 1px solid #e2e8f0; height: fit-content; }
.card-title { font-size: 1.25rem; color: #0f172a; margin-top: 0; margin-bottom: 1.5rem; border-bottom: 2px solid #f1f5f9; padding-bottom: 0.5rem; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.text-pending { font-size: 0.75rem; color: #d97706; display: block; margin-top: 0.2rem; }
.password-rules-box { background: #f8fafc; padding: 1rem; border-radius: 6px; margin-bottom: 1.5rem; border: 1px dashed #cbd5e1; }
.password-rules-list { font-size: 0.75rem; color: #64748b; margin: 0; padding-left: 1rem; }
.btn-dark { background: #0f172a; color: white; border: none; padding: 0.75rem 1.5rem; border-radius: 6px; font-weight: 600; cursor: pointer; width: 100%; transition: opacity 0.2s; }
.btn-dark:hover { opacity: 0.9; }
.btn-block { width: 100%; display: block; }

/* ==========================================================================
   8. PÁGINA DE INICIO (SAAS)
   ========================================================================== */
.layout-frontend .app-container { display: block; width: 100%; }
.layout-frontend .main-content { width: 100%; display: flex; flex-direction: column; align-items: center; }

.content-area { max-width: 1200px; margin: 0 auto; width: 100%; box-sizing: border-box; padding: 2rem 1rem; }

.features-section { width: 100%; }
.section-header { text-align: center; margin-bottom: 3rem; }
.section-title { font-size: 2rem; border: none; color: var(--text-color); margin-bottom: 0.5rem; font-weight: bold; }
.section-subtitle { color: var(--text-muted); font-size: 1.1rem; max-width: 600px; margin: 0 auto; }

.hero-actions { display: flex; gap: 1rem; justify-content: center; margin-top: 2rem; flex-wrap: wrap; }
.btn-outline-light { border: 2px solid white; color: white; padding: 0.75rem 1.5rem; border-radius: 6px; text-decoration: none; font-weight: 600; transition: all 0.3s; }
.btn-outline-light:hover { background: white; color: var(--primary-color); }
.btn-light { background: white; color: var(--primary-color); padding: 0.75rem 1.5rem; border-radius: 6px; text-decoration: none; font-weight: 600; transition: opacity 0.3s; }
.btn-light:hover { opacity: 0.9; }

.feature-icon-wrapper { color: var(--primary-color); margin-bottom: 1.5rem; display: flex; align-items: center; justify-content: flex-start; }

/* ==========================================================================
   9. DASHBOARD Y BACKOFFICE
   ========================================================================== */
.dashboard-container { width: 100%; max-width: 1200px; margin: 0 auto; box-sizing: border-box; }
.dashboard-header h1 { 
    margin-top: 0 !important; 
    margin-bottom: 0; 
    color: #1e293b; 
    font-size: 1.8rem; 
    line-height: 1.2; 
}

.alert-support { background-color: #f0fdfa; border: 1px solid #ccfbf1; border-left: 5px solid #14b8a6; padding: 1.5rem; margin-bottom: 2rem; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 4px 6px rgba(0,0,0,0.05); flex-wrap: wrap; gap: 1rem; }
.alert-support-info { display: flex; flex-direction: column; gap: 0.5rem; }
.alert-support-title { margin: 0; color: #0f766e; font-size: 1.2rem; display: flex; align-items: center; gap: 0.5rem; font-weight: bold; }
.alert-support-text { margin: 0; color: #115e59; font-size: 1rem; line-height: 1.5; }

.btn-support { background-color: #0d9488; color: white; text-decoration: none; padding: 0.75rem 1.5rem; border-radius: 6px; font-weight: bold; display: inline-flex; align-items: center; gap: 0.5rem; transition: background 0.3s; }
.btn-support:hover { background-color: #0f766e; }

.text-muted-center { text-align: center; color: #64748b; padding: 1.5rem; }
.status-text { font-weight: bold; }
.status-active { color: #16a34a; }
.status-inactive { color: #64748b; }

.layout-admin .main-content { padding-top: 0 !important; }
.layout-admin .content-area { margin-top: 0 !important; padding-top: 1rem !important; }

/* ==========================================================================
   LAYOUT ESTRUCTURAL BASE (Compartido Backoffice / Office)
   ========================================================================== */
.layout-admin { height: 100vh; overflow: hidden; display: flex; flex-direction: column; background-color: #f8fafc; }
.app-container, .layout-main { display: flex; flex-direction: row; flex-wrap: nowrap; align-items: stretch; flex: 1; width: 100%; min-height: calc(100vh - 65px); overflow: hidden; }

.topbar { display: flex; justify-content: space-between; align-items: center; height: 65px; background: white; padding: 0 2rem; border-bottom: 1px solid #e2e8f0; flex-shrink: 0; z-index: 10; position: relative; width: 100%; }
.logo-container h2 { margin: 0; color: var(--primary-color, #2563eb); font-size: 1.4rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; }
.top-nav-links { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }
.top-nav-links a { text-decoration: none; color: #475569; font-weight: 600; font-size: 0.9rem; transition: color 0.2s; display: flex; align-items: center; gap: 0.4rem; }
.top-nav-links a:hover { color: var(--primary-color, #2563eb); }

.sidebar { width: 250px; min-width: 250px; background: white; border-right: 1px solid #e2e8f0; padding: 2rem 0; flex-shrink: 0; overflow-y: auto; height: 100%; }
.sidebar-heading, .sidebar-title { padding: 0 2rem; font-size: 0.75rem; color: #94a3b8; font-weight: 700; letter-spacing: 1px; margin-bottom: 1rem; text-transform: uppercase; margin-top: 0; }
.sidebar-menu { list-style: none; padding: 0; margin: 0; }
.sidebar-menu li a { 
    display: flex !important; 
    align-items: center !important; 
    gap: 0.6rem; 
    padding: 0.75rem 2rem; 
    color: #475569; 
    text-decoration: none; 
    font-weight: 600; 
    font-size: 0.95rem; 
    border-left: 4px solid transparent; 
    transition: all 0.2s; 
}

.sidebar-menu li a svg { flex-shrink: 0; display: block; }
.sidebar-menu li a:hover, .sidebar-menu li a.active { background: #f1f5f9; color: var(--primary-color, #2563eb); border-left-color: var(--primary-color, #2563eb); }

.main-content, 
.office-content { 
    padding: 0 !important; 
    flex-grow: 1; 
    width: calc(100% - 250px); 
    overflow-y: auto; 
    background: transparent; 
    display: flex; 
    flex-direction: column; 
}

.content-wrapper { 
    padding: 2rem 2.5rem !important; 
    flex-grow: 1; 
    width: 100%; 
    max-width: 1200px; 
    margin: 0 auto; 
    box-sizing: border-box; 
}

.header-actions { margin-bottom: 2rem; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; }
.header-actions h1 { margin: 0; color: #1e293b; font-size: 1.8rem; }

/* ==========================================================================
   COMPONENTES UI GLOBALES (Tablas, Botones, Formularios, Badges)
   ========================================================================== */
.data-table { width: 100%; border-collapse: collapse; background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
.data-table th, .data-table td { padding: 1rem; text-align: left; border-bottom: 1px solid #e2e8f0; font-size: 0.95rem; }
.data-table th { background: #f8fafc; font-weight: 600; color: #475569; text-transform: uppercase; font-size: 0.85rem; letter-spacing: 0.5px; }

.action-group { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
.btn-icon-action { background: transparent !important; border: none !important; padding: 0; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: color 0.3s ease, transform 0.2s ease; text-decoration: none; }
.btn-icon-action svg { width: 20px; height: 20px; }
.btn-icon-action:hover { transform: translateY(-2px); }

.icon-enter { color: #10b981; } .icon-enter:hover { color: #047857; }
.icon-edit { color: #3b82f6; } .icon-edit:hover { color: #1d4ed8; }
.icon-billing { color: #0ea5e9; } .icon-billing:hover { color: #0369a1; }
.icon-delete { color: #ef4444; } .icon-delete:hover { color: #b91c1c; }
.icon-warning { color: #f59e0b; } .icon-warning:hover { color: #d97706; }

.btn-sm { padding: 0.35rem 0.75rem; border-radius: 6px; font-size: 0.8rem; font-weight: 600; text-decoration: none; border: 1px solid transparent; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; justify-content: center; }
.btn-edit { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; } .btn-edit:hover { background: #dbeafe; transform: translateY(-1px); }
.btn-warning { background: #fef3c7; color: #d97706; border-color: #fde68a; } .btn-warning:hover { background: #fde68a; transform: translateY(-1px); }
.btn-delete { background: #fef2f2; color: #dc2626; border-color: #fecaca; } .btn-delete:hover { background: #fecaca; transform: translateY(-1px); }

.badge { padding: 0.25rem 0.5rem; border-radius: 9999px; font-size: 0.75rem; font-weight: bold; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-action { background: #e0e7ff; color: #4f46e5; padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: bold; letter-spacing: 0.5px; }

.form-wrapper { width: 100%; padding-top: 1rem; }
.form-container { width: 100%; max-width: 550px; background: white; padding: 2.5rem; border-radius: 12px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); box-sizing: border-box; margin: 0 auto 2rem auto; }
.form-container h2 { margin-top: 0; margin-bottom: 2rem; color: #1e293b; font-size: 1.5rem; text-align: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 0.5rem; }
.btn-submit { width: 100%; background: var(--primary-color, #2563eb); color: white; border: none; padding: 1rem; font-size: 1rem; border-radius: 8px; font-weight: bold; cursor: pointer; transition: background 0.2s; margin-top: 0.5rem; }
.btn-submit:hover { filter: brightness(0.9); }
.btn-submit.btn-warning { background: #d97706; color: white; } .btn-submit.btn-warning:hover { background: #b45309; }
.btn-cancel { display: block; text-align: center; margin-top: 1rem; color: #64748b; text-decoration: none; font-size: 0.9rem; } .btn-cancel:hover { color: #334155; text-decoration: underline; }

/* ==========================================================================
   MODALES GLOBALES (Ventanas Emergentes)
   ========================================================================== */
.modal-overlay {
    position: fixed; inset: 0; background-color: rgba(15, 23, 42, 0.75); 
    z-index: 1000; display: none; align-items: center; justify-content: center; 
    padding: 1rem; backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }

.modal-content {
    background: var(--bg-color, #ffffff); border-radius: 12px; width: 100%; 
    max-height: 90vh; display: flex; flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); position: relative; overflow: hidden;
}

.modal-header {
    padding: 1.5rem; border-bottom: 1px solid #e2e8f0; display: flex; 
    justify-content: space-between; align-items: center; background: var(--bg-color, #ffffff);
}
.modal-body { padding: 1.5rem; overflow-y: auto; flex-grow: 1; }
.modal-footer {
    padding: 1.5rem; border-top: 1px solid #e2e8f0; display: flex; 
    justify-content: flex-end; gap: 1rem; background: #f8fafc;
}

.btn-icon-transparent { background: transparent; border: none; cursor: pointer; color: #64748b; display: inline-flex; align-items: center; transition: color 0.2s; }
.btn-icon-transparent:hover { color: var(--primary-color, #2563eb); }
.btn-cancel-modal {
    background-color: #f1f5f9 !important;
    color: #475569 !important;
    border: 1px solid #cbd5e1 !important;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-cancel-modal:hover {
    background-color: #e2e8f0 !important;
    color: #1e293b !important;
    transform: translateY(-1px);
}
.btn-icon-transparent { 
    background: transparent !important; 
    border: none !important; 
    outline: none !important;
    cursor: pointer; 
    color: #64748b; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s; 
}
.btn-icon-transparent:hover { 
    color: #ef4444 !important;
    background: #fef2f2 !important;
}

/* RESPONSIVE LAYOUT GLOBAL */
@media (max-width: 768px) {
    .main-content, .content { width: 100%; padding: 1.5rem; }
    .sidebar { position: absolute; left: 0; top: 0; bottom: 0; z-index: 100; transform: translateX(-100%); box-shadow: 4px 0 15px rgba(0,0,0,0.1); }
    .sidebar.active { transform: translateX(0); }
}