@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;600;800&display=swap');

:root {
    --primary: #004b87;
    --primary-light: #0073cc;
    --secondary: #f43f5e;
    --dark: #0f172a;
    --light: #f8fafc;
    --glass: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    
    /* Fluid Typography - Ajustada para mayor legibilidad y compacidad en móviles */
    --fs-base: clamp(0.95rem, 1vw + 0.5rem, 1.1rem); /* Base: ~15px en móvil */
    --fs-xl: clamp(1.6rem, 5vw + 0.5rem, 3.2rem);   /* Títulos H1: ~25px en móvil */
    --fs-lg: clamp(1.25rem, 3vw + 0.5rem, 1.8rem);  /* Títulos H2: ~20px en móvil */
    --fs-md: clamp(1.1rem, 2vw + 0.5rem, 1.3rem);   /* Títulos H3: ~17.6px en móvil */
    --fs-sm: 0.85rem;                               /* Pequeño: 13.6px */
}

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

html {
    overflow-x: hidden;
}

body {
    font-family: 'Inter', sans-serif;
    font-size: var(--fs-base);
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: var(--dark);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

body.page-cursos {
    background: transparent; /* Removemos el fondo por defecto para usar el pseudo-elemento */
}

body.page-cursos::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background-image: linear-gradient(rgba(241, 245, 249, 0.85), rgba(226, 232, 240, 0.92)), url('../img/fondo-cursos.png');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
}

/* Typography */
h1 { font-size: var(--fs-xl); line-height: 1.1; margin-bottom: 1rem; }
h2 { font-size: var(--fs-lg); line-height: 1.2; margin-bottom: 0.8rem; }
h3 { font-size: var(--fs-md); line-height: 1.2; }

h1, h2, h3 {
    font-family: 'Outfit', sans-serif;
    color: var(--primary);
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

.title-glow {
    text-align: center;
    font-weight: 800;
    margin: clamp(1.5rem, 5vh, 3rem) 0;
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: glow 3s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 0 0 10px rgba(0, 75, 135, 0.1); }
    to { text-shadow: 0 0 20px rgba(244, 63, 94, 0.2); }
}

/* Navbar */
.navbar {
    background: var(--glass);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem clamp(1rem, 5%, 5rem);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.logo {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: clamp(1.1rem, 2vw + 0.5rem, 1.5rem);
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Container */
.container {
    width: min(90%, 1400px);
    margin: 0 auto;
    flex-grow: 1;
    padding: clamp(2rem, 5vh, 4rem) 2rem;
}

/* Search Bar */
.search-container {
    position: relative;
    max-width: 700px;
    margin: 2rem auto 3rem auto;
}

.search-input {
    width: 100%;
    padding: 1.2rem 1.5rem 1.2rem 3.5rem;
    font-size: 1.1rem;
    border-radius: 50px;
    border: 1px solid var(--glass-border);
    background: var(--glass);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    box-shadow: var(--shadow);
    color: var(--dark);
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 75, 135, 0.15);
    background: rgba(255, 255, 255, 0.95);
}

.search-icon {
    position: absolute;
    left: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    pointer-events: none;
}

/* Course Grid */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(280px, 100%, 350px), 1fr));
    gap: clamp(1rem, 3vw, 2.5rem);
    margin-top: 1rem;
}

/* Glass Card */
.course-card {
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: clamp(1.5rem, 4vw, 2.5rem);
    box-shadow: var(--shadow);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.course-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    cursor: default;
}

.course-header h2 {
    margin-bottom: 0;
    flex: 1;
}

.expand-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--primary);
    cursor: pointer;
    transition: transform 0.3s ease;
    padding: 0.5rem;
    margin-left: 1rem;
    align-items: center;
    justify-content: center;
}

.course-details {
    display: block;
    margin-top: 1.5rem;
}

.course-info {
    margin: 1.5rem 0;
    flex-grow: 1;
}

.info-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.8rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Badge variants */
.badge-morning { background: #fdf6e3; color: #d97706; border: 1px solid #fde68a; }
.badge-afternoon { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-weekend { background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe; }
.badge-sunday { background: #fce7f3; color: #be185d; border: 1px solid #fbcfe8; }
.badge-mon-wed-fri { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.badge-tue-thu { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.badge-generic-1 { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.badge-generic-2 { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.badge-generic-3 { background: #faf5ff; color: #7e22ce; border: 1px solid #e9d5ff; }

/* Gallery Section */
.gallery-section {
    width: 100%;
}

.gallery-grid {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 1.5rem;
    padding: 1rem 0 2.5rem 0;
    
    /* Scrollbar Styling */
    scrollbar-width: thin;
    scrollbar-color: var(--primary) #e2e8f0;
}

.gallery-grid::-webkit-scrollbar {
    height: 8px;
}

.gallery-grid::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 10px;
}

.gallery-grid::-webkit-scrollbar-thumb {
    background-color: var(--primary);
    border-radius: 10px;
}

.gallery-item {
    position: relative;
    flex: 0 0 calc(33.333% - 1rem); /* 3 items per view on desktop */
    height: 350px;
    border-radius: 24px;
    overflow: hidden;
    scroll-snap-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    background: var(--glass);
    border: 1px solid var(--glass-border);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: grab;
}

.gallery-item:active {
    cursor: grabbing;
}

.gallery-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 75, 135, 0.15);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.gallery-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.4) 0%, transparent 40%);
    opacity: 0.8;
    pointer-events: none;
}

@media (max-width: 1100px) {
    .gallery-item {
        flex: 0 0 calc(50% - 1rem); /* 2 items per view on tablet */
    }
}

@media (max-width: 768px) {
    .gallery-item {
        flex: 0 0 85%; /* 1 item per view with peek of next on mobile */
        height: 300px;
    }
}

/* Form Styles */
.form-container {
    background: var(--glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: clamp(1.2rem, 5vw, 3rem);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.form-section {
    margin-bottom: 2.5rem;
}

.form-section-title {
    font-size: var(--fs-md);
    color: var(--primary);
    border-bottom: 2.5px solid var(--primary-light);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(200px, 100%, 300px), 1fr));
    gap: clamp(1rem, 2vw, 1.5rem);
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #475569;
}

.form-control {
    width: 100%;
    max-width: 100%;
    padding: 0.8rem 1rem;
    border: 1.5px solid #cbd5e1;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    transition: all 0.2s;
    text-overflow: ellipsis;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2rem;
    padding-right: 2.5rem;
}

/* Custom Select */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    width: 100%;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    font-size: var(--fs-base);
    font-weight: 500;
    color: var(--dark);
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.custom-select-trigger::after {
    content: '';
    width: 12px;
    height: 12px;
    border-right: 2px solid #64748b;
    border-bottom: 2px solid #64748b;
    transform: rotate(45deg);
    transition: all 0.3s;
    margin-left: 10px;
    margin-top: -5px;
}

.custom-select-trigger.open {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 75, 135, 0.1);
}

.custom-select-trigger.open::after {
    transform: rotate(-135deg);
    margin-top: 5px;
}

.custom-select-options {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-10px);
    transition: all 0.3s;
    z-index: 100;
    max-height: 300px;
    overflow-y: auto;
}

.custom-select-options.show {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    transform: translateY(0);
}

.custom-option {
    padding: 0.8rem 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.95rem;
    overflow-wrap: break-word;
}

.custom-option:last-child {
    border-bottom: none;
}

.custom-option:hover {
    background: #f8fafc;
    color: var(--primary);
}

.custom-option.selected {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 600;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 75, 135, 0.1);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-weight: 700;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    width: 100%;
    font-family: 'Inter', sans-serif;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 75, 135, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 75, 135, 0.3);
}

/* Footer */
footer {
    padding: 3rem 2rem;
    text-align: center;
    color: #64748b;
    font-size: 0.9rem;
}

/* Admin Table Responsive */
.admin-table-container {
    overflow-x: auto;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    min-width: 800px; /* Force scroll on mobile for admin table */
}

.admin-table th, .admin-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

.admin-table th {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.admin-table tbody tr {
    transition: background-color 0.2s ease;
}

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

/* Admin Modals */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    overflow-y: auto;
}

.modal-content {
    background: white;
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    max-width: 700px;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modalSlide 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlide {
    from { opacity: 0; transform: scale(0.95) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
    position: absolute;
    right: 1.5rem;
    top: 1.5rem;
    border: none;
    background: #f1f5f9;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #e2e8f0;
    color: #ef4444;
    transform: rotate(90deg);
}

/* Step Indicator */
.step-indicator {
    display: none;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.step-dot {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    position: relative;
    transition: all 0.3s;
}

.step-dot.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 0 4px rgba(0, 75, 135, 0.1);
}

.step-dot.completed {
    background: #10b981;
    color: white;
}

.step-dot:not(:last-child)::after {
    content: '';
    position: absolute;
    right: -1.5rem;
    top: 50%;
    width: 1.5rem;
    height: 2px;
    background: #e2e8f0;
}

.step-nav {
    display: none;
    gap: 1rem;
    margin-top: 2rem;
}

/* Utils */
.fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

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

@media (max-width: 768px) {
    .container {
        padding: 1rem 1rem;
    }

    /* Reducción de tamaños de títulos específicos para móvil */
    h1 { font-size: 1.6rem !important; }
    h2 { font-size: 1.2rem !important; }
    
    .course-card {
        padding: 1.2rem;
        border-radius: 20px;
    }
    
    /* Collapsible Course Cards */
    .course-header {
        cursor: pointer;
    }
    .course-header h2 {
        font-size: 1.15rem; /* Título del curso un poco más pequeño en el header */
    }
    .expand-toggle {
        display: flex;
    }
    .course-details {
        display: none;
        opacity: 0;
        margin-top: 1rem;
    }
    .course-card.expanded .course-details {
        display: block;
        animation: fadeInDetails 0.3s ease forwards;
    }
    .course-card.expanded .expand-toggle {
        transform: rotate(180deg);
    }
    
    .form-container {
        border-radius: 0;
        border-left: none;
        border-right: none;
        padding: 1.2rem 1rem;
    }
    .form-control {
        font-size: 0.95rem;
        padding: 0.7rem 2.5rem 0.7rem 0.8rem;
    }
    .search-input {
        padding-left: 3.2rem;
        font-size: 1rem;
    }
    .btn {
        padding: 0.8rem;
        font-size: 1rem;
    }
}

@keyframes fadeInDetails {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
