/* ============================================================
   Courses App Styles — Mondragon Data Services
   Uses CSS variables from core/css/style.css
   ============================================================ */

/* Hero Section */
.courses-hero,
.course-hero {
    padding: 3rem 0 2rem;
}

.courses-hero .section-title,
.course-hero .course-title {
    font-size: 2.2rem;
    color: var(--white);
    margin-bottom: 0.5rem;
}

.courses-hero .section-subtitle,
.course-hero .course-short-desc {
    color: var(--text-color);
    opacity: 0.8;
    font-size: 1.1rem;
    max-width: 600px;
}

/* ---- Catalog Filters ---- */
.catalog-filters {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1.25rem;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.filter-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-label {
    color: var(--text-color);
    opacity: 0.7;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 0.5rem;
}

.filter-chip {
    display: inline-block;
    padding: 0.35rem 0.9rem;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-color);
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    text-decoration: none;
    transition: all 0.2s;
}

.filter-chip:hover {
    border-color: var(--white);
    color: var(--white);
}

.filter-chip.active {
    background: var(--white);
    color: var(--bg-color);
    border-color: var(--white);
    font-weight: 600;
}

/* ---- Course Grid ---- */
.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.course-card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-color);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.course-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.course-card-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--bg-color);
}

.course-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.course-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--border-color);
}

.course-card-placeholder svg {
    width: 48px;
    height: 48px;
}

.course-card-placeholder.small svg {
    width: 32px;
    height: 32px;
}

.course-badge {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-free {
    background: var(--success-color);
    color: #fff;
}

.badge-featured {
    background: var(--warning-color);
    color: #1a1a1a;
}

.course-card-body {
    padding: 1.25rem;
    flex: 1;
}

.course-category-tag {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--info-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 0.4rem;
    text-decoration: none;
}

.course-card-title {
    font-size: 1.1rem;
    color: var(--white);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.course-card-desc {
    font-size: 0.9rem;
    opacity: 0.7;
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.course-card-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.meta-item {
    font-size: 0.8rem;
    opacity: 0.6;
}

/* Level badges */
.level-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.level-beginner {
    background: rgba(39, 174, 96, 0.15);
    color: #27ae60;
}

.level-intermediate {
    background: rgba(243, 156, 18, 0.15);
    color: #f39c12;
}

.level-advanced {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}

.course-card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.course-instructor {
    font-size: 0.85rem;
    opacity: 0.7;
}

.course-price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--white);
}

.course-price.price-free {
    color: var(--success-color);
}

/* ---- Course Detail ---- */
.course-hero-grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 2rem;
    align-items: start;
}

.course-meta-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.course-instructor-row {
    font-size: 0.95rem;
    opacity: 0.8;
}

.course-instructor-row strong {
    color: var(--white);
}

.course-thumb-large {
    width: 100%;
    border-radius: 12px;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.course-cta-box {
    padding: 1.5rem;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-top: 1rem;
}

.course-price-large {
    font-size: 2rem;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 1rem;
    text-align: center;
}

.course-price-large.price-free {
    color: var(--success-color);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: var(--white);
    color: var(--bg-color);
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    color: var(--white);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--white);
}

.btn-block {
    width: 100%;
    margin-bottom: 0.75rem;
}

.btn-small {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
}

/* Course content */
.course-content {
    padding: 2rem 0 4rem;
}

.course-content-grid {
    max-width: 800px;
}

.course-description {
    margin-bottom: 3rem;
}

.course-description h2,
.course-curriculum h2 {
    font-size: 1.5rem;
    color: var(--white);
    margin-bottom: 1.5rem;
}

.rich-text {
    color: var(--text-color);
    line-height: 1.8;
}

.rich-text h2, .rich-text h3 {
    color: var(--white);
    margin: 1.5rem 0 0.75rem;
}

.rich-text ul, .rich-text ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

/* Module accordion */
.module-accordion {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.module-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: none;
    border: none;
    color: var(--white);
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

.module-header:hover {
    background: rgba(255, 255, 255, 0.03);
}

.module-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.module-number {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--bg-color);
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.module-title {
    font-size: 1rem;
    font-weight: 600;
}

.module-meta {
    font-size: 0.8rem;
    opacity: 0.6;
}

.chevron {
    width: 20px;
    height: 20px;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.module-accordion.open .chevron {
    transform: rotate(180deg);
}

.module-lessons {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.module-accordion.open .module-lessons {
    max-height: 2000px;
}

.lesson-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem 0.75rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.lesson-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.lesson-row-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.lesson-icon,
.lesson-check {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.lesson-icon svg {
    width: 16px;
    height: 16px;
}

.lesson-icon.play {
    color: var(--success-color);
}

.lesson-icon.locked {
    color: var(--neutral-color);
    opacity: 0.5;
}

.lesson-check svg {
    width: 16px;
    height: 16px;
}

.lesson-check.completed {
    color: var(--success-color);
}

.lesson-title-link {
    color: var(--white);
    text-decoration: none;
    font-size: 0.9rem;
}

.lesson-title-link:hover {
    text-decoration: underline;
}

.lesson-title-text {
    color: var(--text-color);
    opacity: 0.5;
    font-size: 0.9rem;
}

.preview-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    background: rgba(39, 174, 96, 0.15);
    color: var(--success-color);
}

.lesson-duration {
    font-size: 0.8rem;
    opacity: 0.5;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* ---- Auth Pages ---- */
.auth-section {
    padding: 4rem 0;
    display: flex;
    justify-content: center;
}

.auth-card {
    max-width: 440px;
    width: 100%;
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    padding: 2.5rem;
}

.auth-title {
    font-size: 1.8rem;
    color: var(--white);
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    color: var(--text-color);
    opacity: 0.7;
    margin-bottom: 2rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
}

.form-input,
.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--white);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-input:focus,
.auth-form input:focus {
    outline: none;
    border-color: var(--white);
}

.form-error {
    color: #e74c3c;
    font-size: 0.8rem;
}

.form-help {
    font-size: 0.75rem;
    opacity: 0.5;
}

.has-error .form-input,
.has-error input {
    border-color: #e74c3c;
}

.auth-form .btn {
    margin-top: 0.5rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.7;
}

.auth-footer a {
    color: var(--white);
    font-weight: 600;
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Alert */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-success {
    background: rgba(39, 174, 96, 0.1);
    border: 1px solid rgba(39, 174, 96, 0.3);
    color: #27ae60;
}

.alert-warning {
    background: rgba(243, 156, 18, 0.1);
    border: 1px solid rgba(243, 156, 18, 0.3);
    color: #f39c12;
}

.alert-error {
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid rgba(231, 76, 60, 0.3);
    color: #e74c3c;
}

/* ---- Dashboard ---- */
.dashboard-section {
    padding: 2rem 0 4rem;
}

.dashboard-header h1 {
    font-size: 1.8rem;
    color: var(--white);
    margin-bottom: 2rem;
}

.dashboard-block {
    margin-bottom: 3rem;
}

.dashboard-block-title {
    font-size: 1.3rem;
    color: var(--white);
    margin-bottom: 1.25rem;
}

.dashboard-courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}

.dashboard-course-card {
    display: flex;
    gap: 1rem;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 1.25rem;
    transition: border-color 0.2s;
}

.dashboard-course-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.dashboard-course-thumb {
    width: 120px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-color);
}

.dashboard-course-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dashboard-course-info {
    flex: 1;
    min-width: 0;
}

.dashboard-course-info h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.dashboard-course-info h3 a {
    color: var(--white);
    text-decoration: none;
}

.dashboard-course-info h3 a:hover {
    text-decoration: underline;
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background: var(--bg-color);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.35rem;
}

.progress-bar {
    height: 100%;
    background: var(--success-color);
    border-radius: 3px;
    transition: width 0.3s;
    min-width: 0;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    opacity: 0.6;
    margin-bottom: 0.5rem;
}

/* Recently watched */
.recent-list {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.recent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    text-decoration: none;
    color: var(--text-color);
    transition: background 0.2s;
}

.recent-item:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.recent-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.recent-course-name {
    display: block;
    font-size: 0.75rem;
    opacity: 0.5;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.recent-lesson-name {
    color: var(--white);
    font-size: 0.95rem;
}

.badge-completed {
    font-size: 0.75rem;
    color: var(--success-color);
    font-weight: 600;
}

.recent-time {
    font-size: 0.8rem;
    opacity: 0.5;
}

/* ---- Video Player Page ---- */
.player-section {
    padding: 0;
}

.player-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    min-height: calc(100vh - 120px);
}

.player-main {
    display: flex;
    flex-direction: column;
}

.player-wrapper {
    width: 100%;
    background: #000;
    aspect-ratio: 16 / 9;
    position: relative;
}

.player-wrapper video,
.player-wrapper .plyr {
    width: 100%;
    height: 100%;
}

.player-no-video {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-color);
    opacity: 0.5;
    background: var(--bg-color);
}

.lesson-info {
    padding: 1.5rem 2rem 2rem;
}

.lesson-breadcrumb {
    font-size: 0.8rem;
    opacity: 0.5;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.lesson-title {
    font-size: 1.5rem;
    color: var(--white);
    margin: 0.25rem 0;
}

.lesson-description {
    margin-top: 1rem;
    color: var(--text-color);
    opacity: 0.8;
    line-height: 1.6;
}

.lesson-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Player Sidebar */
.player-sidebar {
    background: var(--card-bg);
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    max-height: calc(100vh - 120px);
    position: sticky;
    top: 120px;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 5;
}

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

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    display: none;
}

.sidebar-module {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-module.active {
    background: rgba(255, 255, 255, 0.02);
}

.sidebar-module-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--white);
}

.sidebar-module-num {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: var(--bg-color);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.sidebar-lessons {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-lesson {
    position: relative;
}

.sidebar-lesson a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem 0.5rem 2.5rem;
    text-decoration: none;
    color: var(--text-color);
    font-size: 0.85rem;
    transition: background 0.15s;
}

.sidebar-lesson a:hover {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-lesson.current a {
    background: rgba(255, 255, 255, 0.08);
    color: var(--white);
    font-weight: 600;
}

.sidebar-lesson.current::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--white);
    border-radius: 0 2px 2px 0;
}

.sidebar-lesson.watched a {
    opacity: 0.6;
}

.sidebar-check,
.sidebar-play {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.sidebar-check {
    color: var(--success-color);
}

.sidebar-play {
    color: var(--text-color);
    opacity: 0.4;
}

.sidebar-lesson-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-lesson-dur {
    font-size: 0.75rem;
    opacity: 0.5;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* ---- Lesson Comments ---- */
.lesson-comments {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.comments-title {
    font-size: 1.2rem;
    color: var(--white);
    margin-bottom: 1.25rem;
}

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.comment-form textarea {
    resize: vertical;
    min-height: 70px;
}

.comment-form .btn {
    align-self: flex-end;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.comment-item {
    padding: 1rem 1.25rem;
    background: var(--card-bg);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.comment-author {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--white);
}

.comment-date {
    font-size: 0.75rem;
    opacity: 0.5;
}

.comment-content {
    font-size: 0.9rem;
    color: var(--text-color);
    line-height: 1.6;
    margin: 0;
}

.comments-empty {
    text-align: center;
    opacity: 0.5;
    font-size: 0.9rem;
    padding: 1.5rem 0;
}

/* ---- Plyr Overrides ---- */
.plyr--video {
    border-radius: 0;
}

.plyr__control--overlaid {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
}

.plyr--full-ui input[type=range] {
    color: var(--white);
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state h3 {
    color: var(--white);
    margin-bottom: 0.5rem;
}

.empty-state p {
    opacity: 0.6;
    margin-bottom: 1.5rem;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .course-hero-grid {
        grid-template-columns: 1fr;
    }

    .player-layout {
        grid-template-columns: 1fr;
    }

    .player-sidebar {
        position: static;
        max-height: none;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    .sidebar-toggle {
        display: block;
    }

    .sidebar-modules.collapsed {
        display: none;
    }
}

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

    .dashboard-courses-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-course-card {
        flex-direction: column;
    }

    .dashboard-course-thumb {
        width: 100%;
        height: 140px;
    }

    .auth-card {
        padding: 1.5rem;
    }

    .lesson-info {
        padding: 1rem;
    }
}
