/* =============================================================================
   VARIABLES & DESIGN SYSTEM
   ============================================================================= */
:root {
    --bg-dark: #090a0f;
    --card-bg: rgba(25, 28, 41, 0.45);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --primary: #6366f1; /* Indigo */
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.35);
    
    --success: #10b981; /* Emerald */
    --success-glow: rgba(16, 185, 129, 0.2);
    
    --danger: #ef4444; /* Red */
    --danger-glow: rgba(239, 68, 68, 0.2);
    
    --warning: #f59e0b; /* Amber */
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --radius-lg: 16px;
    --radius-md: 10px;
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* =============================================================================
   BASE STYLES
   ============================================================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow-x: hidden;
    padding: 2rem 1rem;
}

/* =============================================================================
   BACKGROUND DECORATIVE BLOCKS
   ============================================================================= */
.background-decor {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.15;
    mix-blend-mode: screen;
    animation: float 25s infinite ease-in-out alternate;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    top: -10%;
    right: -10%;
}

.blob-2 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #ec4899 0%, transparent 70%);
    bottom: -15%;
    left: -10%;
    animation-delay: -5s;
}

.blob-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #3b82f6 0%, transparent 70%);
    top: 40%;
    left: 30%;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(40px, -60px) scale(1.1); }
    100% { transform: translate(-20px, 20px) scale(0.95); }
}

/* =============================================================================
   LAYOUT CONTAINER
   ============================================================================= */
.container {
    width: 100%;
    max-width: 800px;
    z-index: 1;
}

.header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, #fff 30%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 300;
    max-width: 600px;
    margin: 0 auto;
}

/* =============================================================================
   CARD & GLASSMORPHISM
   ============================================================================= */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.form-section h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.step-num {
    background: var(--primary);
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-size: 0.95rem;
    font-weight: 700;
    box-shadow: 0 0 15px var(--primary-glow);
}

/* =============================================================================
   FORM INPUTS & LABELS
   ============================================================================= */
.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

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

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.required {
    color: var(--danger);
}

input[type="text"],
input[type="email"],
select {
    width: 100%;
    padding: 0.85rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: all var(--transition-fast);
}

input[type="text"]:focus,
input[type="email"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

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

select option {
    background-color: #171923;
    color: var(--text-primary);
}

.error-msg {
    color: var(--danger);
    font-size: 0.8rem;
    height: 1.2rem;
    display: block;
    margin-top: 0.25rem;
    font-weight: 400;
}

.error-msg.centered {
    text-align: center;
    height: auto;
    margin-top: 1rem;
    font-size: 0.9rem;
}

/* =============================================================================
   COURSES SELECTION SECTION
   ============================================================================= */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.4rem 0.8rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.badge.active {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: #a5b4fc;
}

.section-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.courses-grid {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Curso Item Individual */
.course-item {
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.02);
    overflow: hidden;
    transition: all var(--transition-smooth);
}

.course-item:hover:not(.disabled) {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.04);
}

.course-header {
    display: flex;
    align-items: center;
    padding: 1.25rem;
    cursor: pointer;
    user-select: none;
}

.course-checkbox-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    margin-right: 1rem;
}

.course-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    outline: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
}

.course-checkbox:checked {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.course-checkbox:checked::after {
    content: "";
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

.course-checkbox:disabled {
    border-color: rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.01);
    cursor: not-allowed;
}

.course-info {
    flex-grow: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.course-name {
    font-weight: 500;
    font-size: 1.05rem;
    transition: color var(--transition-fast);
}

.course-capacity-badge {
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-weight: 600;
}

/* Estados de Item de Curso */
.course-item.selected {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.06);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.05);
}

.course-item.selected .course-name {
    color: #a5b4fc;
}

.course-item.selected .course-capacity-badge {
    background: rgba(99, 102, 241, 0.15);
    color: #c7d2fe;
}

.course-item.disabled {
    opacity: 0.5;
}

.course-item.disabled .course-header {
    cursor: not-allowed;
}

.course-item.full .course-capacity-badge {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

/* =============================================================================
   DYNAMIC COUNTRY SELECTOR PANEL
   ============================================================================= */
.country-selector-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-smooth);
    background: rgba(0, 0, 0, 0.2);
    border-top: 0px solid transparent;
}

.course-item.selected .country-selector-panel {
    max-height: 180px; /* Suficiente espacio para las filas */
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.country-grid-inner {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.country-selectors {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 580px) {
    .country-selectors {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    .course-item.selected .country-selector-panel {
        max-height: 300px;
    }
}

.country-select-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.country-select-group label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.country-select-group select {
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
}

/* =============================================================================
   BUTTONS
   ============================================================================= */
.form-actions {
    margin-top: 2.5rem;
    display: flex;
    justify-content: center;
}

.btn {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 1.05rem;
    padding: 1rem 2.5rem;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
    color: #fff;
    box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.5);
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* Loading Spinners */
.loading-spinner {
    text-align: center;
    padding: 3rem 0;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.05);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

.btn-spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =============================================================================
   TOAST NOTIFICATIONS
   ============================================================================= */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
    width: calc(100% - 40px);
}

.toast {
    background: rgba(17, 24, 39, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text-primary);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateX(120%);
    transition: transform var(--transition-smooth);
}

.toast.show {
    transform: translateX(0);
}

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-success .toast-icon { color: var(--success); }

.toast-error { border-left: 4px solid var(--danger); }
.toast-error .toast-icon { color: var(--danger); }

.toast-warning { border-left: 4px solid var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }

/* =============================================================================
   MODAL DIALOG
   ============================================================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(9, 10, 15, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    width: 100%;
    max-width: 500px;
    text-align: center;
    transform: scale(0.9);
    transition: transform var(--transition-smooth);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.success-icon {
    width: 64px;
    height: 64px;
    color: var(--success);
    margin: 0 auto 1.5rem;
    animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

.modal h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.modal p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.receipt-details {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 2rem;
    text-align: left;
    font-size: 0.9rem;
}

.receipt-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.receipt-row:last-child {
    border-bottom: none;
}

.receipt-row .label {
    color: var(--text-muted);
}

.receipt-row .value {
    color: var(--text-primary);
    font-weight: 500;
}

.receipt-courses-list {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.receipt-course-card {
    background: rgba(255, 255, 255, 0.03);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border-left: 3px solid var(--primary);
}

.receipt-course-name {
    font-weight: 600;
    color: #c7d2fe;
}

.receipt-course-countries {
    font-size: 0.75rem;
    color: var(--text-secondary);
}
