/* HSE Admin - Premium UI & Ultra-Stable Logic (v6.4) */

:root {
    --sidebar-width: 260px;
    --navy: #0e1b3d;
    --navy-dark: #081025;
    --accent: #ffcc00;
    --blue-lite: #3498db;
    --blue-hover: #2980b9;
    --bg-color: #f4f7f6;
    --surface-color: #ffffff;
    --text-main: #2d3436;
    --text-muted: #636e72;
    --text-white: #ffffff;
    --border-color: #dfe6e9;
    --shadow-sm: 0 2px 5px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --sidebar-item-hover: rgba(255,255,255,0.08);
    --sidebar-item-active: rgba(255,255,255,0.12);
}

body.dark-theme {
    --navy: #000000;
    --navy-dark: #000000;
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --text-main: #f1f2f6;
    --text-muted: #a4b0be;
    --border-color: #2d3436;
    --shadow-md: 0 4px 20px rgba(0,0,0,0.5);
}

body.dark-theme input, 
body.dark-theme select, 
body.dark-theme textarea {
    background: #2a2a2a !important;
    color: #ffffff !important;
    border-color: #444 !important;
}

body.dark-theme .editor-toolbar {
    background: #2d3436;
    border-color: #444;
}

body.dark-theme .editor-btn {
    background: #3d4446;
    color: #f1f2f6;
    border-color: #555;
}

body.dark-theme #course-description {
    background: #1e1e1e !important;
    color: #ffffff !important;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background: var(--bg-color);
    color: var(--text-main);
    transition: 0.3s ease-in-out;
}

/* Layout */
.admin-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Refactor */
.admin-sidebar {
    width: var(--sidebar-width);
    background: var(--navy);
    background: linear-gradient(180deg, var(--navy) 0%, var(--navy-dark) 100%);
    color: var(--text-white);
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
}

.admin-logo {
    padding: 30px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.admin-logo img {
    width: 65px;
    height: 65px;
    padding: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    margin-bottom: 12px;
    box-shadow: 0 8px 15px rgba(0,0,0,0.2);
}

.admin-logo span {
    display: block;
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--accent);
}

.admin-sidebar nav {
    flex: 1;
    padding: 10px 0;
    overflow-y: auto;
}

.sidebar-section-label {
    padding: 20px 25px 10px;
    font-size: 0.65rem;
    font-weight: 800;
    color: rgba(255,255,255,0.4);
    letter-spacing: 2px;
    text-transform: uppercase;
}

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

.admin-sidebar nav ul li {
    padding: 12px 25px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 15px;
    color: #cbd5e1;
    font-weight: 600;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9rem;
    position: relative;
    border-left: 4px solid transparent;
}

.admin-sidebar nav ul li i {
    width: 22px;
    text-align: center;
    font-size: 1.1rem;
    opacity: 0.7;
    transition: 0.3s;
}

.admin-sidebar nav ul li:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.admin-sidebar nav ul li:hover i { opacity: 1; color: var(--accent); }

.admin-sidebar nav ul li.active {
    background: linear-gradient(90deg, rgba(255, 204, 0, 0.1) 0%, transparent 100%);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 700;
}

.admin-sidebar nav ul li.active i { opacity: 1; color: var(--accent); }

/* Sync Button in Sidebar */
.btn-sync {
    background: linear-gradient(135deg, var(--blue-lite) 0%, #2980b9 100%);
    color: white;
    border: none;
    width: 100%;
    padding: 14px 20px;
    border-radius: 12px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: 0.3s;
    font-size: 0.85rem;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.btn-sync:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(52, 152, 219, 0.4);
}

.btn-sync i { animation: fa-spin 5s infinite linear; }
.btn-sync:hover i { animation: none; }

/* --- SIDEBAR SUBMENU v9.6 --- */
.has-submenu {
    flex-direction: column !important;
    align-items: flex-start !important;
    padding: 0 !important;
}

.submenu-trigger {
    padding: 12px 25px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 15px;
    color: #b2bec3;
    transition: 0.3s;
}

.has-submenu:hover .submenu-trigger { color: white; }
.has-submenu.open .submenu-trigger { color: var(--accent); }

.submenu-trigger i.chevron-icon {
    margin-left: auto;
    font-size: 0.8rem;
    transition: 0.3s;
}

.has-submenu.open i.chevron-icon { transform: rotate(180deg); }

.sidebar-submenu {
    width: 100%;
    list-style: none;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(0,0,0,0.15);
}

.has-submenu.open .sidebar-submenu {
    max-height: 500px; /* Suficiente para varios grupos */
}

.sidebar-submenu li {
    padding: 10px 25px 10px 50px;
    font-size: 0.85rem;
    color: #94a3b8;
    cursor: pointer;
    transition: 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-submenu li:hover {
    color: white;
    background: rgba(255,255,255,0.05);
    border-left-color: var(--blue-lite);
}

.sidebar-submenu li i { font-size: 0.75rem; color: #25d366; }

/* --- HEADER TITLE LINK --- */
.workspace-course-title-link {
    color: inherit;
    text-decoration: none;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.workspace-course-title-link:hover {
    color: #25d366 !important;
    text-decoration: underline;
}

.workspace-course-title-link i { color: #25d366; }

.admin-sidebar hr {
    border: 0;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin: 10px 25px;
}

.sidebar-footer {
    padding: 20px 25px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.btn-logout {
    width: 100%;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: #fab1a0;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 700;
    transition: 0.3s;
}

.btn-logout:hover {
    background: #e17055;
    color: white;
    border-color: #e17055;
}

/* Main Area */
.admin-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 40px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.admin-header h2 {
    font-size: 1.8rem;
    color: var(--navy);
    font-weight: 800;
}

body.dark-theme .admin-header h2 { color: white; }

.admin-profile {
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--surface-color);
    padding: 6px 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: 0.3s;
}

.admin-profile:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--blue-lite);
}

.admin-user-info {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.user-display-name {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--navy);
    line-height: 1.2;
}

.role-badge {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--blue-lite);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-avatar-wrapper {
    width: 40px;
    height: 40px;
    background: rgba(52, 152, 219, 0.1);
    color: var(--blue-lite);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

body.dark-theme .user-display-name { color: white; }

/* Stats Refactor v7.5 - Linear & Compact */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--surface-color);
    padding: 18px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: 0.3s;
    border: 1px solid var(--border-color);
}

.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.stat-card i {
    font-size: 1.4rem;
    background: rgba(52, 152, 219, 0.08);
    color: var(--blue-lite);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.stat-card h3 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
}

.stat-card p {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-top: 5px;
}

@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* Section Cards */
.admin-section { animation: fadeIn 0.4s ease-out; }

.section-card {
    background: var(--surface-color);
    padding: 40px;
    border-radius: 20px;
    box-shadow: var(--shadow-md);
}

.section-card h3 {
    margin-bottom: 30px;
    font-size: 1.5rem;
    color: var(--navy);
    border-left: 5px solid var(--accent);
    padding-left: 15px;
}

body.dark-theme .section-card h3 { color: white; }

/* Forms Refactor */
.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 10px;
}

.flex-2 { flex: 2; }

.form-group { margin-bottom: 25px; }

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px 18px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: transparent;
    color: var(--text-main);
    font-size: 1rem;
    transition: 0.3s;
}

.form-group input:focus {
    border-color: var(--blue-lite);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.curriculum-header {
    background: var(--blue-lite);
    color: white;
    padding: 12px 25px;
    border-radius: 8px;
    font-weight: 800;
    margin: 30px 0 20px;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

/* Premium Editor Toolbar */
.editor-toolbar {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-bottom: none;
    padding: 10px 15px;
    border-radius: 12px 12px 0 0;
    display: flex;
    gap: 8px;
    align-items: center;
}

.editor-btn {
    background: white;
    border: 1px solid #e2e8f0;
    color: #475569;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.editor-btn:hover {
    background: #f1f5f9;
    border-color: var(--blue-lite);
    color: var(--blue-lite);
    transform: translateY(-1px);
}

.editor-btn i { font-size: 0.85rem; }

#course-description {
    border-top: none;
    border-radius: 0 0 12px 12px;
    min-height: 250px;
    resize: vertical;
    line-height: 1.6;
    padding: 20px;
    background: #fff;
}

#course-description:focus {
    border-color: var(--blue-lite);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.1);
    outline: none;
}

/* Buttons */
.btn {
    padding: 12px 30px;
    border-radius: 10px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #f1f5f9;
    color: var(--navy);
}

.btn:hover {
    background: #e2e8f0;
}

.btn-blue { background: var(--blue-lite); color: white; }
.btn-save { background: var(--navy); color: white; width: 100%; justify-content: center; }
.btn-save:hover { background: var(--navy-dark); }

/* Courses Grid */
.admin-courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    padding-top: 10px;
}

.admin-course-card {
    background: var(--surface-color);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.admin-course-card:hover { 
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

.admin-course-img-wrapper {
    height: 190px;
    position: relative;
    overflow: hidden;
}

.admin-course-img-wrapper img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    transition: transform 0.5s ease;
}

.admin-course-card:hover .admin-course-img-wrapper img {
    transform: scale(1.1);
}

.admin-tag {
    position: absolute;
    top: 15px; left: 15px;
    background: var(--accent);
    color: black;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    z-index: 10;
}

.content-cell { 
    padding: 25px; 
    flex: 1;
    display: flex;
    flex-direction: column;
}

.content-cell h4 { 
    margin-bottom: 10px; 
    font-size: 1.25rem; 
    color: var(--navy);
    font-weight: 700;
}

.content-cell .price { 
    color: var(--blue-lite); 
    font-weight: 800; 
    margin-bottom: 20px; 
    font-size: 1.1rem;
}

.content-cell .actions {
    margin-top: auto;
    display: flex;
    gap: 12px;
}

.btn-small {
    padding: 8px 15px;
    font-size: 0.85rem;
}

.btn-delete {
    background: #fff5f5;
    color: #e74c3c;
    border: 1px solid #fee2e2;
}

.btn-delete:hover {
    background: #e74c3c;
    color: white;
}

/* Login */
.login-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--navy);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000;
}

.login-card {
    background: var(--surface-color);
    padding: 50px;
    border-radius: 20px;
    width: 100%;
    max-width: 450px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}

/* Course Workspace v9.0 - Advanced Tabs & Builder */
.course-workspace-header {
    background: var(--surface-color);
    margin: -40px -40px 30px -40px;
    padding: 20px 40px 0 40px;
    border-bottom: 1px solid var(--border-color);
}

.course-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.course-tabs-nav {
    display: flex;
    gap: 30px;
    list-style: none;
}

.course-tab-item {
    padding: 15px 5px;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: 0.3s;
}

.course-tab-item:hover { color: var(--blue-lite); }
.course-tab-item.active {
    color: var(--blue-lite);
    border-bottom-color: var(--blue-lite);
}

.workspace-panel {
    animation: fadeIn 0.3s ease;
}

/* Stats in Workspace */
.internal-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-top: 20px;
}

.stat-box {
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.stat-box h4 { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 10px; }
.stat-box .value { font-size: 1.5rem; font-weight: 800; color: var(--navy); }

/* --- NEW CONTENT BUILDER v2.0 (Google Sites Inspired) --- */
.builder-layout-v2 {
    display: flex;
    height: 100%;
    background: #f1f5f9;
}

.builder-canvas-area {
    flex: 1;
    overflow-y: auto;
    padding: 40px 20px;
}

.builder-canvas-container {
    max-width: 850px;
    margin: 0 auto;
    min-height: 100%;
    background: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border-radius: 4px;
    padding: 60px;
    position: relative;
}

.builder-canvas-v2 {
    min-height: 400px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.empty-canvas-state {
    text-align: center;
    padding: 100px 20px;
    color: #94a3b8;
}

.empty-canvas-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-canvas-state h4 {
    font-size: 1.2rem;
    color: #64748b;
    margin-bottom: 10px;
}

/* Sidebar Styles */
.builder-sidebar-right {
    width: 320px;
    background: white;
    border-left: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
}

.builder-tabs-top {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
}

.builder-tabs-top button {
    flex: 1;
    padding: 15px;
    border: none;
    background: none;
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.builder-tabs-top button.active {
    color: var(--blue-lite);
    border-bottom-color: var(--blue-lite);
}

.sidebar-main-tools {
    padding: 20px;
}

.tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    gap: 8px;
}

.tool-btn:hover {
    background: #f1f5f9;
    border-color: var(--blue-lite);
    color: var(--blue-lite);
}

.tool-btn i {
    font-size: 1.2rem;
    color: #64748b;
}

.tool-btn:hover i { color: var(--blue-lite); }

.tool-btn span {
    font-size: 0.75rem;
    font-weight: 500;
}

.sidebar-section-divider {
    font-size: 0.7rem;
    font-weight: 700;
    color: #94a3b8;
    padding: 10px 20px;
    background: #f8fafc;
    letter-spacing: 1px;
}

.layout-presets-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 20px;
}

.layout-preset {
    aspect-ratio: 16/9;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
}

.layout-preset:hover {
    border-color: var(--blue-lite);
    background: #eff6ff;
}

.preset-icon i {
    font-size: 1.2rem;
    color: #94a3b8;
}

.sidebar-scrollable-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.component-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 25px;
    cursor: pointer;
    transition: background 0.2s;
}

.component-item:hover {
    background: #f8fafc;
}

.component-item i {
    width: 20px;
    text-align: center;
    color: #64748b;
    font-size: 1rem;
}

.component-item span {
    font-size: 0.85rem;
    color: #334155;
    font-weight: 500;
}

/* Block styles (Rendered in Canvas) */
.builder-block {
    position: relative;
    padding: 20px;
    border: 1px solid transparent;
    border-radius: 8px;
    transition: 0.2s;
}

.builder-block:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.block-controls {
    position: absolute;
    left: -15px;
    top: 0;
    transform: translateX(-100%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border: 1px solid #e2e8f0;
    z-index: 100;
}

.builder-block:hover .block-controls {
    opacity: 1;
    left: -20px;
}

.block-toolbar-v8-horizontal {
    display: flex;
    flex-direction: row;
    gap: 8px;
    background: #ffffff;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    margin-bottom: 12px;
    width: fit-content;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.3s ease;
}

.builder-block:hover .block-toolbar-v8-horizontal {
    opacity: 1;
    transform: translateY(0);
}

.block-btn-v8 {
    height: 32px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
}

.block-btn-v8:hover {
    background: white;
    border-color: var(--blue-lite);
    color: var(--blue-lite);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.color-picker-v8 {
    position: relative;
    height: 32px;
}

.color-picker-v8 input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.color-picker-v8 i {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 0.9rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    z-index: 1;
    transition: 0.2s;
}

.color-picker-v8:hover i {
    color: var(--blue-lite);
    border-color: var(--blue-lite);
    background: white;
}

.block-btn {
    width: 32px;
    height: 32px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #64748b;
    font-size: 0.8rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: 0.2s;
}

.block-btn:hover {
    color: var(--blue-lite);
    border-color: var(--blue-lite);
    transform: scale(1.1);
}

.block-btn.delete:hover {
    color: #ef4444;
    border-color: #fca5a5;
    background: #fef2f2;
}

/* Header hierarchies for blocks */
.block-text-h1 { font-size: 2.5rem; font-weight: 800; color: var(--navy); margin-bottom: 0.5em; }
.block-text-h2 { font-size: 1.8rem; font-weight: 700; color: var(--navy); margin-bottom: 0.5em; border-left: 5px solid var(--blue-lite); padding-left: 15px; }
.block-text-h3 { font-size: 1.4rem; font-weight: 700; color: #334155; margin-bottom: 0.4em; }
.block-text-h4 { font-size: 1.1rem; font-weight: 600; color: #475569; margin-bottom: 0.3em; text-transform: uppercase; letter-spacing: 1px; }
.block-text-p { font-size: 1rem; line-height: 1.6; color: #334155; }

.block-video-wrapper {
    background: #000;
    aspect-ratio: 16/9;
    border-radius: 12px;
    overflow: hidden;
    margin: 20px 0;
}

.block-video-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.block-pdf-wrapper {
    height: 600px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    margin: 20px 0;
    background: #f8fafc;
}

.block-pdf-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
}
/* Administrative Tables (Students/Orders) */
.table-responsive {
    overflow-x: auto;
    margin-top: 10px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

.admin-table th {
    background: #f8fafc;
    padding: 15px;
    color: #64748b;
    font-weight: 600;
    border-bottom: 2px solid #edf2f7;
}

.admin-table td {
    padding: 15px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.admin-table tr:hover {
    background: #fdfdfd;
}

/* Status Badges for Students */
.status-pill {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
}

.status-pill.active {
    background: #def7ec;
    color: #03543f;
}

/* --- GROUPS SYSTEM STYLES (v9.5) --- */
.group-setup-grid {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 30px;
}

.group-config-card {
    background: white;
    padding: 30px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.whatsapp-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.whatsapp-input-wrapper i {
    position: absolute;
    left: 15px;
    color: #25d366;
    font-size: 1.2rem;
}

.whatsapp-input-wrapper input {
    padding-left: 45px !important;
    border-color: #25d36644;
}

.whatsapp-input-wrapper input:focus {
    border-color: #25d366;
    box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.1);
}

.group-members-list {
    margin-top: 30px;
}

.member-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: #f8fafc;
    border-radius: 12px;
    margin-bottom: 10px;
    transition: 0.2s;
    border: 1px solid transparent;
}

.member-row:hover {
    background: white;
    border-color: var(--blue-lite);
    transform: translateX(5px);
    box-shadow: var(--shadow-sm);
}

.member-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.member-avatar {
    width: 40px;
    height: 40px;
    background: var(--navy);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
}

.member-details h5 {
    font-size: 0.95rem;
    color: var(--navy);
    margin-bottom: 2px;
}

.member-details p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.whatsapp-badge {
    background: #25d366;
    color: white;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.empty-group-state {
    text-align: center;
    padding: 60px 20px;
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 20px;
}

.empty-group-state i {
    font-size: 3rem;
    color: #cbd5e1;
    margin-bottom: 20px;
}

.empty-group-state h4 {
    color: var(--navy);
    margin-bottom: 10px;
}

.empty-group-state p {
    color: var(--text-muted);
    font-size: 0.9rem;
    max-width: 300px;
    margin: 0 auto 20px;
}

.status-pill.pending {
    background: #fef3c7;
    color: #92400e;
}

.student-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.student-avatar {
    width: 35px;
    height: 35px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
}

.meta-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f1f1f1;
    font-size: 0.85rem;
}

.meta-item label { color: var(--text-muted); font-weight: 500; }
.meta-item span { font-weight: 700; color: var(--navy); }

.status-badge {
    background: #e1f7e1;
    color: #27ae60 !important;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.editable-meta {
    color: var(--blue-lite) !important;
    cursor: pointer;
    text-decoration: underline dotted;
}

.btn-text-red {
    background: none; border: none; color: #e74c3c; font-size: 0.85rem; font-weight: 600; padding: 0; cursor: pointer;
}

.collapsible-card .card-header-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.sidebar-item-list { margin-top: 15px; }

.search-box input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.85rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive Builder */
@media (max-width: 1200px) {
    .builder-layout { flex-direction: column; }
    .builder-sidebar { width: 100%; position: static; }
}
/* --- QUIZ BUILDER & TABLES --- */
.quiz-tab-item {
    padding: 15px 5px;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: 0.3s;
}
.quiz-tab-item:hover { color: var(--blue-lite); }
.quiz-tab-item.active {
    color: var(--blue-lite);
    border-bottom-color: var(--blue-lite);
}

.table-responsive {
    overflow-x: auto;
    margin-top: 10px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th {
    text-align: left;
    padding: 15px;
    background: #f8fafc;
    color: #64748b;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
}

.admin-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 0.95rem;
    vertical-align: middle;
}

.admin-table tr:hover { background: #f8fafc; }

.item-icon.icon-q { background: #f59e0b; color: white; }
.item-icon.icon-l { background: #3b82f6; color: white; }

.btn-icon-sm {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    margin: 0 2px;
}

.btn-icon-sm:hover {
    background: #f1f5f9;
    color: var(--blue-lite);
    border-color: var(--blue-lite);
}

.btn-icon-sm.delete:hover {
    background: #fef2f2;
    color: #ef4444;
    border-color: #fca5a5;
}

.btn-outline {
    background: white;
    border: 1px solid var(--blue-lite);
    color: var(--blue-lite);
}

.btn-outline:hover {
    background: var(--blue-lite);
    color: white;
}

#quiz-questions-container .builder-item {
    transition: transform 0.2s, box-shadow 0.2s;
}

#quiz-questions-container .builder-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.quiz-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--navy);
}

#quiz-total-points-badge {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    font-family: inherit;
    font-weight: 800;
}

#quiz-questions-container .builder-item .form-group input[type="number"] {
    border-color: #e2e8f0;
    text-align: center;
    font-weight: 700;
    color: var(--navy);
}

/* --- FACILITATORS UI --- */
.image-upload-box {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #f8fafc;
}

.image-upload-box:hover {
    border-color: var(--blue-lite) !important;
    background: #f1f5f9;
}

.image-upload-box img {
    border-radius: 12px;
}

.admin-courses-grid .admin-course-card {
    display: flex;
    flex-direction: column;
}

.admin-courses-grid .admin-course-card .content-cell {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.admin-courses-grid .admin-course-card .actions {
    margin-top: auto;
    display: flex;
    gap: 10px;
}

.btn-small {
    padding: 8px 12px;
    font-size: 0.8rem;
    border-radius: 8px;
}

/* --- RESPONSIVE ADMIN --- */
.sidebar-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
    backdrop-filter: blur(3px);
}

.sidebar-overlay.active { display: block; }

.sidebar-toggle {
    display: none;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--navy);
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.2rem;
    margin-right: 15px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s;
}

.sidebar-toggle:hover { background: #f8fafc; color: var(--blue-lite); }

@media (max-width: 1024px) {
    .sidebar-toggle { display: block; }
    
    .admin-sidebar {
        left: -300px; /* Hidden off-canvas */
        transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        width: 280px;
        box-shadow: none;
    }

    .admin-sidebar.active {
        left: 0;
        box-shadow: 10px 0 30px rgba(0,0,0,0.3);
    }

    .admin-main {
        margin-left: 0;
        padding: 20px;
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        gap: 20px;
    }

    .admin-header {
        margin-bottom: 25px;
    }

    .admin-header h2 {
        font-size: 1.3rem;
    }

    .internal-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .admin-courses-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .internal-stats {
        grid-template-columns: 1fr;
    }
    
    .section-card {
        padding: 20px;
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .admin-profile {
        align-self: flex-end;
        width: auto;
    }
}


/* --- UPLOAD PROGRESS BAR v8.0 --- */
.progress-container-v8 {
    width: 100%;
    background: #e2e8f0;
    border-radius: 50px;
    height: 8px;
    margin: 10px 0;
    overflow: hidden;
    display: none; /* Se muestra vía JS */
    position: relative;
}

.progress-bar-v8 {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--blue-lite) 0%, #2ecc71 100%);
    transition: width 0.3s ease;
}

.progress-text-v8 {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--blue-lite);
    margin-top: 5px;
    display: none;
}

/* Enhancements for Doc/Video Blocks */
.builder-block .block-video-wrapper, 
.builder-block .block-pdf-wrapper {
    transition: all 0.3s ease;
}

.uploading-active {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.uploading-active::after {
    content: '\f110';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: var(--blue-lite);
    animation: fa-spin 2s infinite linear;
}
/* --- GRADES TABLE ALIGNMENT FIX --- */
/* Centra todas las celdas de la tabla de notas para que coincidan con los encabezados */
#grades-table-head th,
#grades-table-body td {
    text-align: center !important;
    vertical-align: middle;
}

/* El encabezado de la tabla de notas: fondo premium */
#grades-table-head th {
    background: linear-gradient(135deg, #0e1b3d 0%, #1a3a6e 100%);
    color: white;
    font-size: 0.72rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 800;
    padding: 14px 12px;
    border-bottom: none;
}

/* Pill del curso centrado */
#grades-table-body td .course-pill {
    display: inline-block;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- GRADES TABLE PREMIUM v11.0 (Senior UI Refactor) --- */
.table-container, .table-responsive {
    width: 100%;
    overflow-x: hidden; /* Prevent global horizontal scroll */
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: white;
    margin-top: 15px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.02);
}

.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto; /* Dynamic width management */
}

.admin-table th, .admin-table td {
    padding: 16px 15px;
    text-align: left;
    font-size: 0.88rem;
    vertical-align: middle;
    line-height: 1.4;
    white-space: normal; /* Allow text wrapping */
    word-break: break-word; /* Safety for long emails/links */
}

.admin-table th {
    background: rgba(248, 250, 252, 0.98);
    font-weight: 800;
    color: var(--navy);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.75rem;
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.admin-table td {
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-main);
    transition: background 0.2s ease;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #f8fafc; }

/* Micro-maquetación de celdas */
.student-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.student-info strong {
    font-weight: 700;
    color: var(--navy);
    display: block;
    max-width: 180px;
}

/* Compact Action Column */
.admin-table td:last-child {
    white-space: nowrap; /* Actions should stay together */
    width: 100px;
}

.btn-icon-sm {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    color: var(--navy);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon-sm:hover {
    background: var(--blue-lite);
    color: white;
    transform: translateY(-2px);
}

/* Specific Column Flexibilities */
.col-email { font-size: 0.8rem; color: var(--text-muted); }
.col-course { font-weight: 600; color: var(--blue-lite); }

.student-avatar {
    background: var(--navy);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

/* Senior Responsive Logic */
@media (max-width: 1200px) {
    .admin-main { padding: 25px; }
    .admin-table th, .admin-table td { padding: 12px 10px; }
}

@media (max-width: 1100px) {
    /* Hide non-critical columns on medium screens to favor core data */
    .admin-table th:nth-child(4), .admin-table td:nth-child(4), /* Precio */
    .admin-table th:nth-child(5), .admin-table td:nth-child(5) { display: none; }
}

@media (max-width: 768px) {
    .admin-main { margin-left: 0; }
    .admin-table th:nth-child(2), .admin-table td:nth-child(2) { display: none; } /* Hide Email on Mobile */
    
    .admin-table th, .admin-table td { font-size: 0.8rem; }
    .student-info strong { max-width: 120px; }
}

@media (max-width: 768px) {
    .workspace-actions {
        flex-direction: column;
        align-items: stretch !important;
    }
    .header-search input {
        width: 100% !important;
    }
}

/* Shortcuts Dashboard v11.0 (Mini Action Cards) */
.shortcut-grid-v10 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
}

.shortcut-card {
    background: white;
    padding: 15px 12px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    min-height: 100px;
    justify-content: center;
}

.shortcut-card i {
    font-size: 1.25rem;
    background: rgba(59, 130, 246, 0.08);
    color: var(--blue-lite);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: 0.3s;
}

.shortcut-card span {
    font-weight: 700;
    color: var(--navy);
    font-size: 0.8rem;
    line-height: 1.2;
}

.shortcut-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.06);
    border-color: var(--blue-lite);
    background: #f8fbff;
}

.shortcut-card:hover i {
    background: var(--blue-lite);
    color: white;
    transform: scale(1.1) rotate(-5deg);
}

@media (max-width: 480px) {
    .shortcut-grid-v10 {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .shortcut-card span {
        font-size: 0.75rem;
    }
}
/* --- GRADES CARD SYSTEM v7.0 --- */
.view-toggle {
    display: flex;
    background: #f1f5f9;
    padding: 5px;
    border-radius: 10px;
    gap: 5px;
}

.view-toggle button {
    background: transparent;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.view-toggle button.active {
    background: white;
    color: var(--blue-lite);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.score-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 0.75rem;
    text-align: center;
}

.status-passed {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.status-failed {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.status-pending {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.grades-detailed-list {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 5px;
    margin-top: 10px;
}

.grades-detailed-list::-webkit-scrollbar {
    width: 4px;
}

.grades-detailed-list::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

.grade-item {
    padding: 10px;
    margin-bottom: 5px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #edf2f7;
    transition: 0.2s;
}

.grade-item:hover {
    background: #f1f5f9;
    border-color: var(--blue-lite);
}
