/* ══════════════════════════════════════════════════════════
   PSICOMAGNUM UNED — Estilos del Frontend
   ══════════════════════════════════════════════════════════ */

:root {
    --bg:          #0f1117;
    --bg-card:     #1a1d27;
    --bg-card-hover: #222636;
    --bg-input:    #151821;
    --border:      #2a2e3d;
    --border-hover:#3d4260;
    --text:        #e4e6ef;
    --text-muted:  #8b8fa3;
    --text-dim:    #5c6078;
    --primary:     #6c5ce7;
    --primary-glow:#6c5ce7aa;
    --primary-light:#a29bfe;
    --accent:      #00cec9;
    --accent-glow: #00cec966;
    --success:     #00b894;
    --success-bg:  #00b89422;
    --error:       #ff6b6b;
    --error-bg:    #ff6b6b1a;
    --warning:     #ffd93d;
    --radius:      12px;
    --radius-sm:   8px;
    --radius-lg:   16px;
    --shadow:      0 4px 24px rgba(0,0,0,.3);
    --transition:  .2s cubic-bezier(.4,0,.2,1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }


/* ═══ HEADER ═══ */

.header {
    background: linear-gradient(135deg, #1a1d27 0%, #1e2235 100%);
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
}

.header-badge {
    background: var(--primary);
    color: white;
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}


/* ═══ STEPPER ═══ */

.stepper {
    max-width: 600px;
    margin: 2rem auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0 1rem;
}

.step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.35;
    transition: var(--transition);
}

.step.active {
    opacity: 1;
}

.step.done {
    opacity: 0.7;
}

.step.done .step-num {
    background: var(--success);
    border-color: var(--success);
}

.step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    transition: var(--transition);
}

.step.active .step-num {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
    box-shadow: 0 0 16px var(--primary-glow);
}

.step-label {
    font-size: 0.82rem;
    font-weight: 500;
}

.step-line {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 0.4rem;
    min-width: 20px;
    max-width: 60px;
}


/* ═══ MAIN ═══ */

.main {
    flex: 1;
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
}

.panel {
    animation: fadeIn .35s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.panel-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.3rem;
}

.panel-desc {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.92rem;
}

.back-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.btn-back {
    background: none;
    border: none;
    color: var(--primary-light);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.3rem 0;
    transition: var(--transition);
}
.btn-back:hover {
    color: var(--accent);
}

.crumb {
    color: var(--text-dim);
    font-size: 0.82rem;
}


/* ═══ COURSE/SEMESTER CARDS ═══ */

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.semester-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.6rem;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--primary-glow), transparent);
    opacity: 0;
    transition: var(--transition);
}

.card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(108, 92, 231, .15);
}

.card:hover::before {
    opacity: 0.08;
}

.card-icon {
    font-size: 2.2rem;
    position: relative;
    z-index: 1;
}

.card-label {
    font-weight: 600;
    font-size: 1.05rem;
    position: relative;
    z-index: 1;
}

.card-count {
    font-size: 0.78rem;
    color: var(--text-muted);
    position: relative;
    z-index: 1;
}


/* ═══ SUBJECT LIST ═══ */

.subject-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.selected-count {
    color: var(--primary-light);
    font-size: 0.85rem;
    font-weight: 500;
    margin-left: auto;
}

.subject-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.subject-list::-webkit-scrollbar {
    width: 6px;
}
.subject-list::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 3px;
}
.subject-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.subject-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.subject-item:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
}

.subject-item.selected {
    border-color: var(--primary);
    background: rgba(108, 92, 231, .08);
}

.subject-check {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
    font-size: 0.75rem;
    color: transparent;
}

.subject-item.selected .subject-check {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.subject-name {
    font-weight: 500;
    font-size: 0.92rem;
    flex: 1;
}

.subject-course {
    font-size: 0.75rem;
    color: var(--text-dim);
    white-space: nowrap;
}


/* ═══ BUTTONS ═══ */

.btn-pill {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.45rem 1rem;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}
.btn-pill:hover {
    border-color: var(--primary);
    color: var(--primary-light);
}
.btn-pill.outline {
    background: transparent;
}
.btn-pill.small {
    padding: 0.25rem 0.7rem;
    font-size: 0.75rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #5a4bd1);
    color: white;
    border: none;
    padding: 0.85rem 2rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
    text-decoration: none;
}
.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px var(--primary-glow);
}
.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.85rem 2rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
    text-decoration: none;
}
.btn-secondary:hover {
    border-color: var(--primary);
}

.action-bar {
    display: flex;
    justify-content: center;
    padding: 1rem 0;
}

.btn-icon {
    font-size: 1.1rem;
}


/* ═══ PROGRESS ═══ */

.progress-container {
    max-width: 640px;
    margin: 0 auto;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.progress-stats {
    display: flex;
    gap: 1.5rem;
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 4px;
    width: 0%;
    transition: width .5s ease;
    position: relative;
}

.progress-bar.indeterminate {
    width: 100%;
    background: linear-gradient(90deg, 
        transparent 0%, var(--primary) 30%, var(--accent) 50%, 
        var(--primary) 70%, transparent 100%);
    background-size: 200% 100%;
    animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.progress-detail {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}


/* ═══ LOG ═══ */

.log-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    font-weight: 500;
}

.log-content {
    padding: 0.75rem 1rem;
    max-height: 240px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.78rem;
    line-height: 1.65;
    color: var(--text-muted);
}

.log-content::-webkit-scrollbar {
    width: 5px;
}
.log-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.log-entry {
    padding: 0.1rem 0;
}

.log-time {
    color: var(--text-dim);
    margin-right: 0.5rem;
}


/* ═══ RESULTS ═══ */

.result-box, .error-box {
    text-align: center;
    padding: 2.5rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    animation: fadeIn .4s ease;
}

.result-box {
    border-color: var(--success);
    background: var(--success-bg);
}

.error-box {
    border-color: var(--error);
    background: var(--error-bg);
}

.result-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.result-box h3, .error-box h3 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.result-box p, .error-box p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.download-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.download {
    min-width: 200px;
    justify-content: center;
}


/* ═══ LOADING ═══ */

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    gap: 1.25rem;
}

.loading-container p {
    font-size: 1rem;
    font-weight: 500;
}

.loading-sub {
    color: var(--text-muted) !important;
    font-size: 0.85rem !important;
    font-weight: 400 !important;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}


/* ═══ FOOTER ═══ */

.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-dim);
    font-size: 0.78rem;
    border-top: 1px solid var(--border);
}


/* ═══ RESPONSIVE ═══ */

@media (max-width: 640px) {
    .header { padding: 1rem; }
    .main { padding: 1.25rem 1rem; }
    .card-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .card { padding: 1rem; }
    .card-icon { font-size: 1.6rem; }
    .panel-title { font-size: 1.2rem; }
    .progress-header { flex-direction: column; }
    .download-buttons { flex-direction: column; }
    .stepper { gap: 0; }
    .step-label { display: none; }
}
