/* ==========================================
   ACADEMIA RUTACONECTA - CSS PRINCIPAL
   Siguiendo la línea gráfica de RutaConecta
   ========================================== */

:root {
    --brand: #21a607;
    --brand-light: #34e27b;
    --bg: #0f1115;
    --elev: #141823;
    --stroke: #1f2430;
    --muted: #9aa3b2;
    --text: #e6ebf5;
    --accent: var(--brand);
    --radius: 18px;
    --shadow: 0 10px 25px rgba(0,0,0,.25);
    --light: #f6f7fb;
    --lighter: #ffffff;
    --success: #28b463;
    --warning: #f5b041;
    --error: #e74c3c;
    --info: #3498db;
}

html[data-theme="light"] {
    --bg: #f7f8fb;
    --elev: #ffffff;
    --stroke: #e6e9ef;
    --muted: #5b6472;
    --text: #0c111d;
    --lighter: #f9fafc;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, Arial, sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

.container {
    width: min(1200px, 92%);
    margin-inline: auto;
}

/* ==========================================
   COMPONENTES BASE
   ========================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.2rem;
    border-radius: 14px;
    border: 1px solid var(--stroke);
    background: var(--elev);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand), var(--brand-light));
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow);
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #2ecc71);
    color: white;
    border-color: transparent;
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning), #f39c12);
    color: white;
    border-color: transparent;
}

.btn-danger {
    background: linear-gradient(135deg, var(--error), #c0392b);
    color: white;
    border-color: transparent;
}

.btn-ghost {
    background: transparent;
    border-color: var(--stroke);
}

.btn-sm {
    padding: 0.5rem 0.8rem;
    font-size: 0.9rem;
}

.btn-lg {
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
}

.card {
    background: var(--elev);
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.card-body {
    padding: 1.2rem;
}

.card-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text);
}

.card-text {
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: color-mix(in srgb, var(--brand) 14%, transparent);
    border: 1px solid var(--stroke);
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--text);
}

.badge-primary {
    background: linear-gradient(135deg, var(--brand), var(--brand-light));
    color: white;
    border-color: transparent;
}

.badge-success {
    background: linear-gradient(135deg, var(--success), #2ecc71);
    color: white;
    border-color: transparent;
}

.badge-warning {
    background: linear-gradient(135deg, var(--warning), #f39c12);
    color: white;
    border-color: transparent;
}

.badge-danger {
    background: linear-gradient(135deg, var(--error), #c0392b);
    color: white;
    border-color: transparent;
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid var(--stroke);
    border-radius: 12px;
    background: var(--elev);
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent);
}

.form-control::placeholder {
    color: var(--muted);
}

.form-control:invalid {
    border-color: var(--error);
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

select.form-control {
    cursor: pointer;
}

input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--brand);
}

.alert {
    padding: 1rem 1.2rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    border: 1px solid;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.alert-success {
    background: color-mix(in srgb, var(--success) 10%, transparent);
    border-color: color-mix(in srgb, var(--success) 30%, var(--stroke));
    color: var(--success);
}

.alert-warning {
    background: color-mix(in srgb, var(--warning) 10%, transparent);
    border-color: color-mix(in srgb, var(--warning) 30%, var(--stroke));
    color: var(--warning);
}

.alert-danger {
    background: color-mix(in srgb, var(--error) 10%, transparent);
    border-color: color-mix(in srgb, var(--error) 30%, var(--stroke));
    color: var(--error);
}

.alert-info {
    background: color-mix(in srgb, var(--info) 10%, transparent);
    border-color: color-mix(in srgb, var(--info) 30%, var(--stroke));
    color: var(--info);
}

.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* ==========================================
   NAVEGACIÓN
   ========================================== */

.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: saturate(180%) blur(8px);
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    border-bottom: 1px solid var(--stroke);
}

.nav-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text);
}

.brand-badge {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    box-shadow: var(--shadow);
    background: linear-gradient(135deg, var(--brand), var(--brand-light));
    color: white;
    font-weight: 800;
    font-size: 1.1rem;
}

/* Logo styles */
.site-logo {
    height: 50px;
    width: auto;
    object-fit: contain;
    max-width: 200px;
}

@media (max-width: 768px) {
    .site-logo {
        height: 40px;
        max-width: 150px;
    }
    
    .brand {
        gap: 0.5rem;
    }
    
    .brand span:not(.brand-badge) {
        display: none; /* Hide text on mobile when logo is present */
    }
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* ==========================================
   HEADER
   ========================================== */

.page-header {
    background:
        radial-gradient(1200px 600px at 90% -10%, color-mix(in srgb, var(--brand) 15%, transparent) 0%, transparent 60%),
        radial-gradient(1200px 600px at -10% 10%, color-mix(in srgb, var(--brand-light) 12%, transparent) 0%, transparent 60%);
    padding: 2rem 0;
    text-align: center;
}

.page-title {
    font-size: clamp(2rem, 4vw, 3rem);
    margin: 0 0 0.5rem 0;
    line-height: 1.2;
    background: linear-gradient(135deg, var(--brand), var(--brand-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-subtitle {
    color: var(--muted);
    font-size: 1.1rem;
    margin: 0;
}

/* ==========================================
   VIDEOS
   ========================================== */

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.video-card {
    background: var(--elev);
    border: 1px solid var(--stroke);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
}

.video-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    border-color: color-mix(in srgb, var(--brand) 30%, var(--stroke));
}

.video-thumbnail {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #0b0d12;
    overflow: hidden;
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.video-card:hover .video-thumbnail img {
    transform: scale(1.05);
}

.video-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.4);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-card:hover .video-play-overlay {
    opacity: 1;
}

.play-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), var(--brand-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    box-shadow: var(--shadow);
}

.video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
}

.video-stats {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    gap: 0.5rem;
}

.video-stat {
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.video-content {
    padding: 1.2rem;
}

.video-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-description {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 1rem;
}

.video-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.video-category {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--brand);
    font-weight: 500;
}

.video-date {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* ==========================================
   BÚSQUEDA Y FILTROS
   ========================================== */

.search-filter-section {
    margin-top: 3rem;
}

.search-container {
    margin-bottom: 1.5rem;
}

.search-form {
    display: flex;
    align-items: stretch;
}

.search-form .form-group {
    display: flex;
    gap: 1rem;
    width: 100%;
    margin-bottom: 0;
}

.search-form .form-control {
    flex: 1;
}

.search-form .btn {
    min-width: 120px;
}

.sort-container {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-top: 1rem;
}

.sort-container label {
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
}

.sort-container .form-control {
    width: auto;
    min-width: 200px;
}

/* ==========================================
   CATEGORÍAS
   ========================================== */

.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--elev);
    border: 1px solid var(--stroke);
    border-radius: 12px;
}

.category-filter {
    padding: 0.5rem 1rem;
    border: 1px solid var(--stroke);
    border-radius: 20px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.category-filter:hover,
.category-filter.active {
    background: linear-gradient(135deg, var(--brand), var(--brand-light));
    color: white;
    border-color: transparent;
    transform: translateY(-1px);
}

/* ==========================================
   ESTADÍSTICAS
   ========================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.stat-card {
    background: var(--elev);
    border: 1px solid var(--stroke);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--brand), var(--brand-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--muted);
    font-size: 1rem;
    font-weight: 500;
}

.stat-trend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--success);
}

.stat-trend.down {
    color: var(--error);
}

.chart-container {
    background: var(--elev);
    border: 1px solid var(--stroke);
    border-radius: 16px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

/* ==========================================
   PANEL ADMINISTRATIVO
   ========================================== */

.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 280px;
    background: var(--elev);
    border-right: 1px solid var(--stroke);
    padding: 1.5rem 0;
}

.admin-main {
    flex: 1;
    padding: 1.5rem;
}

.admin-nav {
    padding: 0 1rem;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    color: var(--text);
    text-decoration: none;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}

.admin-nav-item:hover,
.admin-nav-item.active {
    background: linear-gradient(135deg, var(--brand), var(--brand-light));
    color: white;
}

.admin-nav-item .material-icons {
    font-size: 1.2rem;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--stroke);
}

.admin-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
}

.admin-actions {
    display: flex;
    gap: 0.8rem;
}

.data-table {
    width: 100%;
    background: var(--elev);
    border: 1px solid var(--stroke);
    border-radius: 12px;
    overflow: hidden;
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--stroke);
}

.data-table th {
    background: color-mix(in srgb, var(--brand) 5%, var(--elev));
    font-weight: 600;
    color: var(--text);
}

.data-table tbody tr:hover {
    background: color-mix(in srgb, var(--brand) 8%, var(--elev));
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.page-link {
    padding: 0.6rem 1rem;
    border: 1px solid var(--stroke);
    border-radius: 8px;
    background: var(--elev);
    color: var(--text);
    text-decoration: none;
    transition: all 0.2s ease;
}

.page-link:hover,
.page-link.active {
    background: linear-gradient(135deg, var(--brand), var(--brand-light));
    color: white;
    border-color: transparent;
}

/* ==========================================
   RESPONSIVE
   ========================================== */

@media (max-width: 1024px) {
    .container {
        width: 95%;
    }
    
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) {
    .container {
        width: 100%;
        padding: 0 1rem;
    }
    
    .nav-wrap {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-links {
        flex-direction: column;
        width: 100%;
    }
    
    .nav-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .admin-layout {
        flex-direction: column;
    }
    
    .admin-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--stroke);
    }
    
    .admin-main {
        padding: 1rem;
    }
    
    .admin-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .admin-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .data-table {
        font-size: 0.9rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.6rem;
    }
    
    .video-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .category-filters {
        padding: 0.8rem;
    }
    
    .category-filter {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 2rem;
    }
    
    .search-form .form-group {
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .search-form .btn {
        width: 100%;
    }
    
    .sort-container {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .sort-container .form-control {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    .btn-sm {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .video-content {
        padding: 1rem;
    }
    
    .page-header {
        padding: 1.5rem 0;
    }
    
    .page-title {
        font-size: 1.8rem;
    }
}

/* ==========================================
   UTILIDADES
   ========================================== */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

.w-100 { width: 100%; }
.h-100 { height: 100%; }

.position-relative { position: relative; }
.position-absolute { position: absolute; }
.position-fixed { position: fixed; }

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }

.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ==========================================
   ANIMACIONES
   ========================================== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.animate-fadeIn {
    animation: fadeIn 0.5s ease-out;
}

.animate-slideInUp {
    animation: slideInUp 0.5s ease-out;
}

.animate-slideInRight {
    animation: slideInRight 0.5s ease-out;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

/* ==========================================
   LOADING STATES
   ========================================== */

.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--stroke);
    border-top: 4px solid var(--brand);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================
   ICONOS
   ========================================== */

.material-icons {
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
}