:root {
    --brand-primary: #222f6e;
    --brand-secondary: #2563eb;
    --brand-accent: #eac000;
    --brand-hover: #1a2a60;
    --surface: #ffffff;
    --surface-alt: #f8fbff;
    --border: #e4e9f2;
    --text-main: #1e2a4a;
    --text-muted: #5f687b;
    --text-light: #9ca3af;
    --shadow-sm: 0 2px 8px rgba(34, 47, 110, 0.07);
    --shadow-md: 0 6px 18px rgba(34, 47, 110, 0.1);
}

/* ── Hero ── */
.cv-hero {
    background: linear-gradient(135deg, var(--brand-primary) 0%, #1e3a8a 100%);
    color: #fff;
    padding: 2.2rem 0 0;
}

.cv-hero-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem 2rem;
}

.cv-breadcrumb {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.65);
    margin-bottom: 1rem;
}

.cv-breadcrumb a {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
}

.cv-breadcrumb a:hover { color: #fff; }
.cv-breadcrumb span { margin: 0 0.4rem; }

.cv-level-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(234, 192, 0, 0.18);
    color: var(--brand-accent);
    border: 1px solid rgba(234, 192, 0, 0.35);
    border-radius: 4px;
    padding: 0.25rem 0.75rem;
    margin-bottom: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cv-course-title {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: 0.5rem;
    color: #fff;
}

.cv-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.cv-status-active {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.cv-status-inactive {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
}

/* Stats bar */
.cv-stats-bar {
    display: flex;
    gap: 0;
    background: rgba(0, 0, 0, 0.2);
    margin: 0;
    padding: 0 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.cv-stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1.2rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.85);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.cv-stat:last-child { border-right: none; }

.cv-stat strong {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}

.cv-stat i {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* Action buttons */
.cv-hero-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 1rem 0 0;
}

.cv-btn-start {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--brand-accent);
    color: #000;
    font-weight: 700;
    font-size: 0.9rem;
    padding: 0.6rem 1.4rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    border-bottom: 3px solid #c9a000;
}

.cv-btn-start:hover {
    background: #f0ca00;
    color: #000;
    text-decoration: none;
}

.cv-btn-share {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 600;
    font-size: 0.88rem;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
}

.cv-btn-share:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Share dropdown */
.share-wrapper { position: relative; }

.share-options {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    padding: 0.4rem;
    display: none;
    min-width: 180px;
    z-index: 1000;
    border: 1px solid var(--border);
}

.share-options.show { display: block; }

.share-options a {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.8rem;
    color: var(--text-main);
    text-decoration: none;
    border-radius: 5px;
    gap: 0.7rem;
    font-size: 0.88rem;
}

.share-options a:hover { background: var(--surface-alt); }
.share-options i { color: var(--text-muted); width: 16px; }

/* ── Page body ── */
.cv-body {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 4rem;
}

/* Search */
.cv-search-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.cv-search-wrap { position: relative; }

.cv-search-input {
    width: 100%;
    padding: 0.65rem 1rem 0.65rem 2.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-main);
    background: var(--surface-alt);
    transition: border-color 0.2s;
}

.cv-search-input:focus {
    outline: none;
    border-color: var(--brand-secondary);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.cv-search-icon {
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 0.9rem;
}

.cv-search-dropdown {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    right: 0;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    max-height: 320px;
    overflow-y: auto;
    display: none;
    z-index: 100;
    border: 1px solid var(--border);
}

.cv-search-dropdown.show { display: block; }

.cv-dropdown-header {
    padding: 0.6rem 1rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--brand-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
}

.cv-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1rem;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border);
}

.cv-dropdown-item:last-child { border-bottom: none; }
.cv-dropdown-item:hover { background: var(--surface-alt); }

/* ── Section panels ── */
.cv-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.4rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.cv-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--border);
}

.cv-panel-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--brand-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.cv-panel-title i { color: var(--brand-secondary); font-size: 1rem; }

.cv-count-pill {
    background: var(--brand-primary);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
}

/* View toggle */
.cv-view-toggle {
    display: flex;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.cv-view-toggle button {
    padding: 0.35rem 0.8rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.82rem;
    cursor: pointer;
    font-weight: 500;
}

.cv-view-toggle button.active {
    background: var(--brand-primary);
    color: #fff;
}

/* ── Unit cards ── */
.cv-units-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.cv-units-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.cv-unit-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.2s ease;
    color: var(--text-main);
    position: relative;
    overflow: hidden;
}

.cv-unit-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--brand-primary);
    opacity: 0;
    transition: opacity 0.2s;
}

.cv-unit-card:hover {
    border-color: var(--brand-secondary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--text-main);
}

.cv-unit-card:hover::before { opacity: 1; }

.cv-unit-card.hidden { display: none; }

.cv-unit-icon-wrap {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(34, 47, 110, 0.1);
    color: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

.cv-unit-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.4;
    margin-bottom: 0.5rem;
    flex: 1;
}

.cv-unit-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border);
}

.cv-unit-level {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--brand-primary);
    background: rgba(34, 47, 110, 0.08);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    text-transform: capitalize;
}

.cv-unit-mats {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* List view */
.cv-unit-card.list-view {
    flex-direction: row;
    align-items: center;
    gap: 0.9rem;
    padding: 0.75rem 1rem;
}

.cv-unit-card.list-view .cv-unit-icon-wrap { margin-bottom: 0; }

.cv-unit-card.list-view .cv-unit-footer {
    border-top: none;
    padding-top: 0;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    margin-top: 0;
    flex-shrink: 0;
}

.cv-unit-card.list-view .cv-unit-name {
    font-size: 0.9rem;
    margin-bottom: 0;
}

/* ── Material cards ── */
.cv-materials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.cv-material-card {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.cv-material-card.hidden { display: none; }

.cv-material-card:hover {
    border-color: var(--brand-secondary);
    box-shadow: var(--shadow-md);
}

.cv-mat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cv-mat-type {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
}

.cv-mat-type.type-pdf   { background: #fef2f2; color: #b91c1c; }
.cv-mat-type.type-doc   { background: #eff6ff; color: #1d4ed8; }
.cv-mat-type.type-video { background: #f0fdf4; color: #15803d; }
.cv-mat-type.type-other { background: #f5f5f5; color: #6b7280; }

.cv-mat-date {
    font-size: 0.72rem;
    color: var(--text-light);
}

.cv-mat-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.4;
}

.cv-mat-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.55;
    flex: 1;
}

.cv-mat-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--brand-primary);
    background: rgba(34, 47, 110, 0.07);
    border: 1px solid rgba(34, 47, 110, 0.15);
    border-radius: 5px;
    padding: 0.4rem 0.85rem;
    text-decoration: none;
    align-self: flex-start;
    transition: all 0.15s;
}

.cv-mat-btn:hover {
    background: var(--brand-primary);
    color: #fff;
    text-decoration: none;
}

/* Load more */
.cv-load-more {
    text-align: center;
    margin-top: 1.2rem;
}

.cv-btn-load {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--brand-primary);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.55rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.cv-btn-load:hover {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}

.cv-btn-load.hidden { display: none; }

/* ── Explore more courses ── */
.cv-explore {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.4rem 1.5rem;
    margin-bottom: 1.5rem;
}

.cv-explore-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.2rem;
}

.cv-explore-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--brand-primary);
    margin: 0;
}

.cv-popular-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.cv-popular-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.9rem;
    text-decoration: none;
    color: var(--text-main);
    transition: all 0.2s;
    display: block;
}

.cv-popular-card:hover {
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: var(--text-main);
}

.cv-popular-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--brand-accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.cv-popular-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.4;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cv-popular-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* ── Related courses ── */
.cv-related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.cv-related-card {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.9rem;
    text-decoration: none;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    transition: all 0.2s;
}

.cv-related-card:hover {
    border-color: var(--brand-primary);
    background: var(--surface);
    text-decoration: none;
    color: var(--text-main);
}

.cv-related-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.4;
}

.cv-related-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* ── Empty state ── */
.cv-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}

.cv-empty i {
    font-size: 2.5rem;
    color: var(--border);
    display: block;
    margin-bottom: 0.75rem;
}

.cv-empty h5 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.4rem;
}

.cv-empty p { font-size: 0.85rem; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .cv-course-title { font-size: 1.3rem; }
    .cv-stats-bar { flex-wrap: wrap; }
    .cv-stat { padding: 0.6rem 0.8rem; font-size: 0.8rem; }
    .cv-units-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .cv-materials-grid { grid-template-columns: 1fr; }
    .cv-popular-grid,
    .cv-related-grid { grid-template-columns: repeat(2, 1fr); }
    .cv-hero-actions { flex-wrap: wrap; }
}

@media (max-width: 576px) {
    /* .cv-hero-inner/.cv-body's 1.5rem side padding stacks with #main's own
       layout padding - cutting both down keeps the page from wasting a large
       chunk of a phone screen's width on empty margin outside the cards. */
    .cv-hero-inner { padding-left: 0.5rem; padding-right: 0.5rem; }
    .cv-body { padding-left: 0.5rem; padding-right: 0.5rem; }
}

@media (max-width: 480px) {
    .cv-popular-grid,
    .cv-related-grid { grid-template-columns: 1fr; }
}
