
/* Estilos críticos para móvil - deben estar al inicio */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 10000;
    background: var(--primary-color, #4361ee);
    color: white;
    border: none;
    border-radius: 8px;
    width: 50px;
    height: 50px;
    font-size: 1.8rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: all 0.3s;
}

.mobile-menu-btn:hover {
    background: var(--secondary-color, #3f37c9);
    transform: scale(1.05);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    z-index: 1999;
    transition: all 0.3s;
}

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

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        background: white;
        z-index: 2000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 15px rgba(0,0,0,0.2);
    }
    
    .sidebar.mobile-show {
        left: 0 !important;
    }
    
    .mobile-menu-btn {
        display: block !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding-top: 70px; /* Espacio para el botón de menú */
    }
}



:root {
    --primary-color: #4361ee;
    --secondary-color: #3f37c9;
    --success-color: #4cc9f0;
    --danger-color: #f72585;
    --warning-color: #f8961e;
    --dark-color: #1e1e2f;
    --light-color: #f8f9fa;
    --gray-color: #6c757d;
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 80px;
    --border-radius: 10px;
    --box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--dark-color);
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-header h3,
.sidebar.collapsed .user-info div,
.sidebar.collapsed .sidebar-nav span {
    display: none;
}

.sidebar.collapsed .sidebar-nav li a {
    justify-content: center;
    padding: 15px 0;
}

/* Sidebar Header - Con icono mejorado */
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h3 {
    color: var(--primary-color);
    font-size: 1.2rem;
}

/* Botón de cierre/colapso mejorado */
.sidebar-toggle {
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--gray-color);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.sidebar-toggle:hover {
    background: rgba(67, 97, 238, 0.1);
    color: var(--primary-color);
    transform: rotate(90deg);
}

/* Para móvil, el botón de cierre tiene fondo */
@media (max-width: 768px) {
    .sidebar-toggle {
        background: rgba(0, 0, 0, 0.05);
    }
    
    .sidebar-toggle:hover {
        background: rgba(67, 97, 238, 0.2);
        transform: rotate(90deg);
    }
}

.user-info {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid #eee;
}

.user-info i {
    font-size: 2.5rem;
    color: var(--primary-color);
}

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

.user-info strong {
    font-size: 1rem;
}

.user-info small {
    color: var(--gray-color);
    font-size: 0.85rem;
}

/* Sidebar Navigation */
.sidebar-nav {
    padding: 20px 0;
}

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

.sidebar-nav li {
    margin-bottom: 5px;
}

.sidebar-nav .nav-section {
    padding: 10px 20px;
    color: var(--gray-color);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 20px;
    color: var(--dark-color);
    text-decoration: none;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: rgba(67, 97, 238, 0.1);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.sidebar-nav li a i {
    width: 20px;
    text-align: center;
}

.sidebar-nav li a.logout {
    color: var(--danger-color);
}

.sidebar-nav li a.logout:hover {
    background: rgba(247, 37, 133, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    transition: var(--transition);
}

.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    width: 100%;
    max-width: 400px;
    animation: fadeIn 0.5s ease;
}

.login-box h1 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 10px;
}

.login-box p {
    text-align: center;
    color: var(--gray-color);
    margin-bottom: 30px;
}

.login-form {
    margin-top: 30px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--dark-color);
    font-weight: 500;
}

.form-group label i {
    color: var(--primary-color);
    margin-right: 5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.password-input {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray-color);
    cursor: pointer;
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(67, 97, 238, 0.4);
}

.login-info {
    margin-top: 30px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    text-align: center;
}

/* Dashboard Header */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.dashboard-header h1 {
    color: white;
    font-size: 2rem;
}

.search-box {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-color);
}

.search-box input {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border: none;
    border-radius: 30px;
    font-size: 1rem;
    box-shadow: var(--box-shadow);
}

/* Filters */
.filters {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.filter-select {
    padding: 10px 15px;
    border: none;
    border-radius: var(--border-radius);
    background: white;
    font-size: 0.95rem;
    min-width: 200px;
    cursor: pointer;
}

/* Cursos Grid */
.cursos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    animation: fadeIn 0.5s ease;
}

.curso-card {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    position: relative;
}

.curso-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.curso-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--warning-color);
    color: white;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 1;
}

.curso-portada {
    height: 180px;
    overflow: hidden;
}

.curso-portada img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.curso-card:hover .curso-portada img {
    transform: scale(1.05);
}

.portada-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.portada-placeholder i {
    font-size: 3rem;
    color: rgba(255,255,255,0.5);
}

.curso-content {
    padding: 20px;
}

.curso-content h3 {
    margin-bottom: 10px;
    color: var(--dark-color);
    font-size: 1.2rem;
}

.curso-content p {
    color: var(--gray-color);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 15px;
}

.curso-meta {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    font-size: 0.85rem;
}

.curso-categoria {
    background: #f0f0f0;
    padding: 3px 10px;
    border-radius: 15px;
    color: var(--gray-color);
}

.curso-tipo {
    padding: 3px 10px;
    border-radius: 15px;
    background: #e3f2fd;
    color: var(--primary-color);
}

.curso-footer {
    display: flex;
    justify-content: space-between;
    color: var(--gray-color);
    font-size: 0.85rem;
    margin-bottom: 15px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.btn-ver-curso {
    display: block;
    text-align: center;
    padding: 10px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    text-decoration: none;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.btn-ver-curso:hover {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
}

.no-cursos {
    grid-column: 1 / -1;
    text-align: center;
    padding: 50px;
    background: white;
    border-radius: var(--border-radius);
    color: var(--gray-color);
}

.no-cursos i {
    font-size: 4rem;
    margin-bottom: 20px;
    color: var(--primary-color);
}

/* Admin Tables */
.admin-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--box-shadow);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(67, 97, 238, 0.3);
}

.btn-edit {
    background: var(--warning-color);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    text-decoration: none;
    margin-right: 5px;
}

.btn-delete {
    background: var(--danger-color);
    color: white;
    padding: 5px 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

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

.data-table th {
    background: #f8f9fa;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: var(--dark-color);
}

.data-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
}

.data-table tr:hover {
    background: #f8f9fa;
}

/* Modales */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

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

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-color);
}

/* Alertas */
.alert {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: var(--border-radius);
    color: white;
    animation: slideIn 0.3s ease;
    z-index: 3000;
    box-shadow: var(--box-shadow);
}

.alert-success {
    background: linear-gradient(135deg, #4cc9f0, #4895ef);
}

.alert-error {
    background: linear-gradient(135deg, #f72585, #b5179e);
}

/* Tooltips */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltip-text {
    visibility: hidden;
    background: var(--dark-color);
    color: white;
    text-align: center;
    padding: 5px 10px;
    border-radius: 5px;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 0.85rem;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.mobile-show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .dashboard-header {
        flex-direction: column;
    }
    
    .search-box {
        max-width: 100%;
    }
    
    .cursos-grid {
        grid-template-columns: 1fr;
    }
}

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

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
/* Spinner pequeño */
.spinner-small {
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 10px;
}

.loading-spinner {
    text-align: center;
    padding: 30px;
    color: var(--gray-color);
}

.loading-spinner p {
    margin-top: 10px;
}

/* Estado deshabilitado para botones */
.btn-primary:disabled,
.btn-desasignar:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.error-data {
    color: var(--danger-color);
    text-align: center;
    padding: 20px;
    background: #ffebee;
    border-radius: 5px;
}
/* Estilos para acciones en tablas */
.actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-edit {
    color: #ff9800;
    background: rgba(255, 152, 0, 0.1);
    width: 35px;
    height: 35px;
    border-radius: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    text-decoration: none;
}

.btn-edit:hover {
    background: #ff9800;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 152, 0, 0.3);
}

.btn-edit i {
    font-size: 1.2rem;
}

.btn-delete {
    color: #f44336;
    background: rgba(244, 67, 54, 0.1);
    width: 35px;
    height: 35px;
    border-radius: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    text-decoration: none;
    border: none;
    cursor: pointer;
}

.btn-delete:hover {
    background: #f44336;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(244, 67, 54, 0.3);
}

.btn-delete i {
    font-size: 1.2rem;
}
/* Responsive Design */
@media (max-width: 1024px) {
    .cursos-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    /* Sidebar móvil */
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        background: white;
        z-index: 2000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .sidebar.mobile-show {
        left: 0;
    }
    
    .main-content {
        margin-left: 0 !important;
        width: 100%;
        padding: 20px 15px;
    }
    
    /* Overlay cuando el sidebar está abierto */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1999;
        backdrop-filter: blur(2px);
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    /* Botón de menú móvil */
    .mobile-menu-btn {
        display: block !important;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 1001;
        background: var(--primary-color);
        color: white;
        border: none;
        border-radius: 8px;
        width: 45px;
        height: 45px;
        font-size: 1.5rem;
        cursor: pointer;
        box-shadow: 0 3px 10px rgba(0,0,0,0.2);
        transition: all 0.3s;
    }
    
    .mobile-menu-btn:hover {
        background: var(--secondary-color);
        transform: scale(1.05);
    }
    
    /* Ajustes de la tabla para móvil */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .data-table {
        min-width: 800px;
    }
    
    /* Grid de cursos en móvil */
    .cursos-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Filtros en móvil */
    .filters {
        flex-direction: column;
        gap: 10px;
    }
    
    .filter-select {
        width: 100%;
    }
    
    /* Formularios en móvil */
    .form-container {
        padding: 20px 15px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions button,
    .form-actions a {
        width: 100%;
        margin: 5px 0;
    }
    
    /* Tarjetas de estadísticas en móvil */
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    /* Login en móvil */
    .login-box {
        padding: 30px 20px;
        margin: 15px;
    }
    
    /* Perfil en móvil */
    .profile-form {
        padding: 15px;
    }
    
    /* Header del dashboard en móvil */
    .dashboard-header {
        margin-top: 60px; /* Espacio para el botón de menú */
        padding: 10px 0;
    }
    
    .dashboard-header h1 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    /* Móviles pequeños */
    .sidebar {
        width: 100%;
        max-width: none;
    }
    
    .curso-card {
        margin: 0;
    }
    
    .curso-portada {
        height: 150px;
    }
    
    .curso-content {
        padding: 15px;
    }
    
    .curso-content h3 {
        font-size: 1.1rem;
    }
    
    .badge {
        font-size: 0.75rem;
        padding: 3px 8px;
    }
    
    .btn-primary, 
    .btn-login {
        padding: 12px 20px;
        font-size: 0.95rem;
    }
    
    /* Alertas en móvil */
    .alert {
        width: 90%;
        right: 5%;
        left: 5%;
        top: 10px;
        font-size: 0.9rem;
        padding: 12px 15px;
    }
    
    /* Modales en móvil */
    .modal-content {
        width: 95%;
        padding: 20px;
        margin: 10px;
    }
    
    /* Ajustes de espaciado */
    .admin-section {
        padding: 15px;
    }
    
    .section-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .section-header h1 {
        font-size: 1.3rem;
    }
}

/* Ajustes para orientación horizontal en móviles */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        width: 70%;
        max-width: 400px;
    }
    
    .curso-card {
        max-width: 100%;
    }
    
    .login-box {
        max-width: 500px;
    }
}

/* Mejoras de touch para móviles */
@media (hover: none) and (pointer: coarse) {
    .btn-edit,
    .btn-delete,
    .btn-primary,
    .curso-card {
        -webkit-tap-highlight-color: transparent;
    }
    
    .btn-edit:active,
    .btn-delete:active,
    .btn-primary:active {
        transform: scale(0.95);
    }
    
    .curso-card:active {
        transform: scale(0.98);
    }
}

/* Ajustes para pantallas muy pequeñas */
@media (max-width: 360px) {
    .curso-meta {
        flex-direction: column;
        gap: 5px;
    }
    
    .curso-footer {
        flex-direction: column;
        gap: 5px;
        align-items: flex-start;
    }
    
    .actions {
        flex-wrap: wrap;
    }
}