:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #10b981;
    --bg-color: #f8fafc;
    --text-color: #1e293b;
    --text-light: #64748b;
    --card-bg: rgba(255, 255, 255, 0.8);
    --border-color: #e2e8f0;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);

    /* UI Colors */
    --success: #10b981;
    --success-hover: #059669;
    --info: #0ea5e9;
    --info-hover: #0284c7;
    --warning: #f59e0b;
    --warning-hover: #d97706;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --slate: #64748b;

    /* Accessibility & Typography */
    --font-base: 14px;
    --font-inter: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-inter);
}

html {
    font-size: var(--font-base);
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    min-height: 100vh;
    display: flex; /* Sidebar layout */
    margin: 0;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Base Utilities */
.d-flex { display: flex !important; }
.flex-column { flex-direction: column !important; }
.align-center { align-items: center !important; }
.justify-center { justify-content: center !important; }
.justify-between { justify-content: space-between !important; }
.flex-grow { flex-grow: 1 !important; }
.gap-xs { gap: 0.25rem !important; }
.gap-sm { gap: 0.5rem !important; }
.gap-md { gap: 1rem !important; }
.gap-lg { gap: 1.5rem !important; }

/* Accessibility & UX Helpers */
.page-description {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 0.25rem;
    max-width: 800px;
}

.btn-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.btn-legend {
    font-size: 0.7rem;
    color: #64748b;
    font-weight: 500;
    text-align: center;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: #ffffff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1000;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
    width: 70px;
    min-width: 70px;
}

.sidebar.collapsed .sidebar-header .sidebar-title,
.sidebar.collapsed .sidebar-nav .sidebar-link span,
.sidebar.collapsed .sidebar-nav .course-title span,
.sidebar.collapsed .sidebar-nav .course-title .chevron,
.sidebar.collapsed .font-size-ctrl,
.sidebar.collapsed .sidebar-nav .module-label {
    display: none !important;
}

.sidebar.collapsed .sidebar-nav .sidebar-link,
.sidebar.collapsed .sidebar-nav .course-title {
    justify-content: center;
    padding: 0.75rem 0 !important;
}

.sidebar.collapsed .sidebar-nav i {
    margin: 0 !important;
    min-width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar.collapsed .course-group .course-items {
    display: none;
}

.sidebar.collapsed .desktop-toggle-row {
    justify-content: center !important;
    margin-right: 0 !important;
}

.sidebar-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #f1f5f9;
}

.mobile-close-btn {
    display: none;
}

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

.sidebar-link {
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #475569;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-link:hover {
    background: #f8fafc;
    color: var(--primary-color);
}

.sidebar-link.active {
    background: #eef2ff;
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.sidebar-link i, .course-title i {
    width: 20px;
    height: 20px;
    min-width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.course-group {
    margin-bottom: 0.5rem;
}

.course-title {
    padding: 0.75rem 2rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 0.75rem; /* Space between icon and text */
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    line-height: normal;
}

.course-title span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.course-title:hover {
    background: #f8fafc;
    color: var(--primary-color);
}

.course-title .chevron {
    transition: transform 0.3s ease;
}

.course-group.collapsed .chevron {
    transform: rotate(-90deg);
}

.course-items {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.course-group.collapsed .course-items {
    max-height: 0;
}

/* Main Content */
.main-content {
    flex: 1;
    min-width: 0;
    padding: 1.5rem 2rem;
    overflow-y: auto;
    background: var(--bg-color);
}

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

.card {
    background: #ffffff;
    padding: 2rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    gap: 0.5rem;
    font-size: 0.95rem;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

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

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-success:hover {
    background-color: var(--success-hover);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: var(--danger-hover);
}

.btn-warning {
    background-color: var(--warning);
    color: white;
}

.btn-warning:hover {
    background-color: var(--warning-hover);
}

.btn-secondary {
    background-color: #ffffff;
    color: var(--slate);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #f1f5f9;
    color: var(--text-color);
}

.btn-icon {
    padding: 0.5rem;
    min-width: 38px;
    height: 38px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: #e2e8f0;
    color: var(--primary-color);
    border-color: var(--border-color);
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    color: var(--text-light);
    padding: 0.5rem 0;
    font-size: 0.9rem;
    text-decoration: none;
    font-weight: 500;
    border: none;
    cursor: pointer;
}

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

/* Icon Sizes */
.icon-sm { width: 14px; height: 14px; }
.icon-md { width: 18px; height: 18px; }
.icon-lg { width: 24px; height: 24px; }

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-light);
}

input,
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: #ffffff;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Tables */
.table-container {
    overflow-x: auto;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

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

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #f8fafc;
}

tbody tr:hover {
    background-color: #f1f5f9;
}

/* Zebra striping using semi-transparent overlays */
/* This allows the striping to work on top of status-colored cells */
.table-container table tbody tr:nth-child(even) td,
table.zebra tbody tr:nth-child(even) td,
.table-zebra tbody tr:nth-child(even) td,
.responsive-table tbody tr:nth-child(even) td {
    background-image: linear-gradient(rgba(0,0,0,0.025), rgba(0,0,0,0.025));
}

.table-container table tbody tr:hover td,
table.zebra tbody tr:hover td,
.table-zebra tbody tr:hover td,
.responsive-table tbody tr:hover td {
    background-image: linear-gradient(rgba(0,0,0,0.05), rgba(0,0,0,0.05)) !important;
}

/* Ensure sticky columns inherit the overlay correctly */
.table-container table td.sticky-col,
table.zebra td.sticky-col,
.table-zebra td.sticky-col,
.responsive-table td.sticky-col {
    background-image: none;
}

.table-container table tr:nth-child(even) td.sticky-col,
table.zebra tr:nth-child(even) td.sticky-col,
.table-zebra tr:nth-child(even) td.sticky-col,
.responsive-table tr:nth-child(even) td.sticky-col {
    background-image: linear-gradient(rgba(0,0,0,0.025), rgba(0,0,0,0.025));
}

/* Sticky Table Enhancements */
.sticky-col {
    position: sticky;
    left: 0;
    background-color: #ffffff;
    z-index: 20;
    border-right: 2px solid #e2e8f0;
    box-shadow: 5px 0 5px -3px rgba(0,0,0,0.1);
}

/* Zebra support for sticky columns */
.zebra tbody tr:nth-child(even) .sticky-col {
    background-color: #f8fafc !important;
}

.zebra tbody tr:hover .sticky-col {
    background-color: #f1f5f9 !important;
}

th.sticky-col {
    background-color: #f1f5f9; /* Match header background */
    z-index: 11;
}

@media (max-width: 768px) {
    .table-container {
        border-radius: 0;
        margin: 0 -1.5rem;
        box-shadow: none;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    th:first-child, td:first-child {
        padding-left: 2.5rem !important; /* Espacio extra para no cortarse en esquinas de celulares */
    }
}

/* Badges */
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger { background: #fef2f2; color: #b91c1c; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-info { background: #eff6ff; color: #1d4ed8; }
.badge-admin { background: #ede9fe; color: #6d28d9; }
.badge-user { background: #f1f5f9; color: #475569; }

/* Page Header */
.page-header {
    margin-bottom: 2rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: space-between;
    align-items: center;
}

.page-header h2 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-color);
}

.page-header p {
    color: var(--text-light);
    margin: 0.25rem 0 0;
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.fade-in { animation: fadeIn 0.3s ease-out forwards; }
@keyframes slideDown { 
    from { transform: translateY(-10px); opacity: 0; } 
    to { transform: translateY(0); opacity: 1; } 
}

/* Modals & Overlays */
.obs-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 2rem;
}

.obs-modal {
    background: white;
    padding: 2.5rem;
    border-radius: 20px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: relative;
    animation: slideDown 0.3s ease-out;
}

.obs-modal h3 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-close {
    margin-top: 1.5rem;
    padding: 0.6rem 1.25rem;
    background: #f1f5f9;
    border: none;
    border-radius: 8px;
    color: #475569;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s;
}

.btn-close:hover {
    background: #e2e8f0;
    color: var(--text-color);
}

/* Inline Forms */
.inline-form-container {
    display: none;
    background: #ffffff;
    padding: 3rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05);
    animation: slideDown 0.3s ease-out;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.inline-form-container::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--primary-color);
}

/* Responsive Mobile */
#sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1001;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
    cursor: pointer;
}

@media (max-width: 768px) {
    body { flex-direction: column; }
    .sidebar {
        position: fixed;
        left: -280px;
        transition: left 0.3s ease;
    }
    .sidebar.active { left: 0; }
    .main-content { padding: 1.5rem; width: 100%; }
    #sidebar-toggle { display: block; bottom: 90px !important; }
    .mobile-close-btn { 
        display: block; 
        position: absolute;
        top: 1rem;
        right: 1rem;
    }
    
    .table-container {
        border-radius: 0;
        margin: 0 -1.5rem;
        box-shadow: none;
    }
}
/* Stat Cards */
.stat-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.25rem;
    height: 100%;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon i {
    width: 24px;
    height: 24px;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 0.25rem;
}

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

.animate-up {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.animate-up:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
}

/* User Management & Global Alumnos UI */
.user-name { font-weight: 600; color: #1e293b; }
.user-email { font-size: 0.85rem; color: #64748b; }
.inline-form-row td { padding: 2rem !important; background: #f8fafc; border-top: 1px solid #e2e8f0; border-bottom: 2px solid #cbd5e1; }
.inline-form-container .form-title { margin-top: 0; margin-bottom: 2rem; color: var(--primary-color); font-weight: 800; display: flex; align-items: center; gap: 0.5rem; font-size: 1.1rem; }
.form-actions { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid #e2e8f0; }

.alumnos-global-card { padding: 0; overflow: hidden; }
.alumno-contacto { font-size: 0.85rem; color: #475569; display: flex; align-items: center; gap: 0.5rem; justify-content: flex-end; }
.exceso-alert { display: inline-flex; align-items: center; gap: 0.25rem; background: #fee2e2; color: #991b1b; font-size: 0.65rem; padding: 1px 6px; border-radius: 4px; border: 1px solid #fecaca; font-weight: 700; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }

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


/* Subscription Page Styles */
.subscription-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

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

.subscription-card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s;
}

.subscription-card:hover {
    transform: translateY(-5px);
}

.subscription-card.featured {
    border: 2px solid var(--primary-color);
    position: relative;
}

.subscription-card .price {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 1rem 0;
    color: var(--text-color);
}

.subscription-card .price span {
    font-size: 1rem;
    color: var(--text-light);
    font-weight: 400;
}

.subscription-features {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0;
    flex-grow: 1;
}

.subscription-features li {
    padding: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
}

.contact-card {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    padding: 2rem;
    border-radius: 16px;
    margin-top: 3rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.contact-info h3 { color: white; margin-bottom: 0.5rem; }
.contact-info p { color: #cbd5e1; margin: 0; }

@media (max-width: 768px) {
    .contact-card {
        flex-direction: column;
        text-align: center;
    }
}

/* Rich Text Content Formatting */
.rich-content {
    line-height: 1.6;
    color: var(--text-color);
    font-size: 1rem;
}
.rich-content p {
    margin-bottom: 1rem;
}
.rich-content ul, .rich-content ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}
.rich-content ul {
    list-style-type: disc !important;
}
.rich-content ol {
    list-style-type: decimal !important;
}
.rich-content li {
    margin-bottom: 0.5rem;
}
.rich-content h1, .rich-content h2, .rich-content h3, .rich-content h4, .rich-content h5, .rich-content h6 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-color);
}
.rich-content strong {
    font-weight: 700;
}
.rich-content em {
    font-style: italic;
}
.rich-content blockquote {
    border-left: 4px solid var(--border-color);
    padding-left: 1rem;
    margin-left: 0;
    margin-bottom: 1rem;
    font-style: italic;
    color: var(--text-light);
}
.rich-content table {
    width: 100% !important;
    border-collapse: collapse;
    margin-bottom: 1rem;
}
.rich-content table td, .rich-content table th {
    border: 1px solid var(--border-color) !important;
    padding: 0.5rem !important;
}
.rich-content img {
    max-width: 100%;
    height: auto;
}

/* PDF & Print Utilities */
@media print {
    .no-print { display: none !important; }
    body { background: white !important; }
    .card { border: none !important; box-shadow: none !important; padding: 0 !important; }
}

/* html2pdf specific overrides */
.html2pdf__page-break {
    display: block;
    height: 0;
    page-break-after: always;
}

/* Prevent elements from being split across pages */
.pdf-avoid-break {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

.tp-rich-content {
    background: white !important;
    color: black !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
    height: auto !important;
}

.tp-rich-content * {
    max-width: 100% !important;
    overflow: visible !important;
}

.pdf-export-container {
    width: 800px !important;
    max-width: 800px !important;
    margin: 0 auto !important;
    background: white !important;
    padding: 2.5rem !important;
    box-shadow: none !important;
    border: none !important;
    overflow: visible !important;
}

@media (max-width: 800px) {
    .pdf-export-container {
        width: 100% !important;
    }
}
