/* --- RESET & BASE --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #1389cb;
    --primary-dark: #0d6efd;
    --accent: #f10872;
    --bg: #f5f7fa;
    --bg-card: #fff;
    --bg-dark: #1a1a2e;
    --text: #1e293b;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
    --shadow-lg: 0 4px 20px rgba(0,0,0,.1);
    --transition: .2s ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* --- UTILITY CLASSES --- */
.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.container-sm { max-width: 960px; margin: 0 auto; padding: 0 24px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- LOGIN PAGE --- */
.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}

.login-container { width: 100%; max-width: 420px; padding: 24px; margin: auto; }

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    color: #fff;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-header p {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* --- FORMS --- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--bg);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(19, 137, 203, .15);
    background: #fff;
}

.form-input::placeholder { color: var(--text-muted); }

select.form-input { cursor: pointer; }

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .9rem;
}
.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* --- BUTTONS --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border-color: transparent;
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), #0b5ed7);
    box-shadow: 0 4px 12px rgba(13, 110, 253, .3);
    color: #fff;
    transform: translateY(-1px);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent), #d1066a);
    color: #fff;
}
.btn-accent:hover {
    box-shadow: 0 4px 12px rgba(241, 8, 114, .3);
    color: #fff;
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(19,137,203,.05);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, .3);
    color: #fff;
}

.btn-sm { padding: 6px 14px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; min-width: 36px; }

/* --- ALERTS --- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* --- NAVBAR --- */
.navbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}
.navbar-brand:hover { color: var(--primary); }

.navbar-brand svg {
    width: 32px;
    height: 32px;
    color: var(--primary);
}

.navbar-search {
    flex: 1;
    max-width: 400px;
    margin: 0 32px;
    position: relative;
}

.navbar-search input {
    width: 100%;
    padding: 8px 16px 8px 40px;
    border: 2px solid var(--border);
    border-radius: 99px;
    font-size: .9rem;
    background: var(--bg);
    transition: all var(--transition);
}

.navbar-search input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(19,137,203,.1);
}

.navbar-search::before {
    content: '';
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") no-repeat center;
}

.search-count {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: .75rem;
    color: var(--text-muted);
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-user-info {
    text-align: right;
    line-height: 1.3;
}

.navbar-user-name {
    font-weight: 600;
    font-size: .9rem;
}

.navbar-user-role {
    font-size: .75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
}

/* --- PAGE HEADER --- */
.page-header {
    padding: 32px 0 24px;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
}

.page-header p {
    color: var(--text-light);
    margin-top: 4px;
}

/* --- COURSE GRID --- */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    padding-bottom: 40px;
}

/* --- COURSE CARD --- */
.course-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: box-shadow .3s ease;
    display: flex;
    flex-direction: column;
}

.course-card:hover {
    box-shadow: var(--shadow-lg);
}

.course-card-image {
    position: relative;
    aspect-ratio: 16/10;
    overflow: hidden;
    background: #e2e8f0;
}

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

.course-card-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: linear-gradient(135deg, var(--accent), #d1066a);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.course-card-category {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0,0,0,.6);
    color: #fff;
    font-size: .7rem;
    padding: 4px 10px;
    border-radius: 99px;
    backdrop-filter: blur(4px);
}

.course-card-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.course-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.course-card-title a {
    color: var(--text);
}
.course-card-title a:hover { color: var(--primary); }

.course-card-desc {
    font-size: .85rem;
    color: var(--text-light);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 16px;
    flex: 1;
}

.course-card-progress {
    height: 4px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 16px;
}

.course-card-progress-bar {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    border-radius: 99px;
    transition: width .4s ease;
}

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

.course-card-author {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.course-card-author img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.course-card-author-info {
    min-width: 0;
}

.course-card-author-name {
    font-weight: 600;
    font-size: .85rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.course-card-author-role {
    font-size: .72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.course-card-duration {
    font-size: .8rem;
    color: var(--text-light);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

.course-card-duration svg {
    width: 14px;
    height: 14px;
}

/* --- ADMIN LAYOUT --- */
.admin-layout {
    display: flex;
    min-height: calc(100vh - 64px);
}

.admin-sidebar {
    width: 260px;
    background: var(--bg-dark);
    color: #fff;
    padding: 24px 0;
    flex-shrink: 0;
}

.admin-sidebar-nav { list-style: none; }

.admin-sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: rgba(255,255,255,.7);
    font-size: .9rem;
    font-weight: 500;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}

.admin-sidebar-nav a:hover,
.admin-sidebar-nav a.active {
    background: rgba(255,255,255,.08);
    color: #fff;
    border-left-color: var(--primary);
}

.admin-sidebar-nav svg { width: 20px; height: 20px; flex-shrink: 0; }

.admin-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

/* --- TABLES --- */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.table-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    text-align: left;
    padding: 12px 24px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

table td {
    padding: 14px 24px;
    font-size: .9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table tr:last-child td { border-bottom: none; }

table tr:hover td { background: rgba(19,137,203,.02); }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.badge-admin { background: #ede9fe; color: #6d28d9; }
.badge-user { background: #e0f2fe; color: #0369a1; }
.badge-active { background: #ecfdf5; color: #065f46; }
.badge-inactive { background: #fef2f2; color: #991b1b; }
.badge-count { background: var(--bg); color: var(--text-light); font-size: .8rem; padding: 4px 12px; }

/* --- MODAL --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}

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

.modal-box {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    transform: translateY(20px);
    transition: transform .25s ease;
}

.modal-overlay.active .modal-box {
    transform: translateY(0);
}

.modal-box-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.modal-box-header h3 { font-size: 1.15rem; font-weight: 700; }

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    background: var(--bg);
    cursor: pointer;
    color: var(--text-light);
    transition: all var(--transition);
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-box-body { padding: 24px; }
.modal-box-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--border);
}

/* --- COURSE ASSIGN LIST --- */
.assign-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.assign-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.assign-item:last-child { border-bottom: none; }
.assign-item:hover { background: var(--bg); }

.assign-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.assign-item-info { flex: 1; min-width: 0; }
.assign-item-title { font-weight: 500; font-size: .9rem; }
.assign-item-meta { font-size: .75rem; color: var(--text-muted); }

.assign-search {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

.assign-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .85rem;
}

/* --- STATS CARDS --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-card-label {
    font-size: .85rem;
    color: var(--text-light);
    margin-top: 4px;
}

/* --- VIDEO PLAYER PAGE --- */
.player-layout {
    display: flex;
    height: 100vh;
    background: #000;
}

.player-video-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.player-video-area video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.player-sidebar {
    width: 380px;
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.player-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.player-sidebar-header h2 {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 12px;
}

.player-close {
    float: right;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--bg);
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-light);
    font-size: 1rem;
    text-decoration: none;
    transition: all var(--transition);
}
.player-close:hover { background: var(--border); color: var(--text); }

/* Player Progress */
.player-progress {
    display: flex;
    align-items: center;
    gap: 12px;
}

.player-progress-circle {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.player-progress-circle canvas {
    width: 40px;
    height: 40px;
}

.player-progress-info { flex: 1; }

.player-progress-text {
    font-size: .85rem;
    color: var(--text-light);
}

.player-progress-badge {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 99px;
    margin-left: 6px;
}

.player-progress-count {
    font-weight: 700;
    font-size: 1.1rem;
}

/* Player Tabs */
.player-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.player-tab {
    flex: 1;
    padding: 12px 16px;
    text-align: center;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.player-tab:hover { color: var(--text); }
.player-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Player Lesson List */
.player-lessons {
    flex: 1;
    overflow-y: auto;
}

.player-tab-content { display: none; }
.player-tab-content.active { display: block; }

/* Chapter headings */
.chapter-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg);
    font-weight: 600;
    font-size: .85rem;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.chapter-heading:hover { background: #edf2f7; }

.chapter-heading .chapter-num {
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .72rem;
    font-weight: 700;
    flex-shrink: 0;
}

.chapter-heading .chapter-title { flex: 1; }

.chapter-heading .chapter-time {
    font-size: .75rem;
    color: var(--text-muted);
    font-weight: 400;
}

.chapter-heading .chevron {
    width: 16px;
    height: 16px;
    transition: transform .2s;
}

.chapter-heading.collapsed .chevron { transform: rotate(-90deg); }

/* Lesson items */
.chapter-lessons { /* wrapper che collapse */ }
.chapter-lessons.collapsed { display: none; }

.lesson-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px 10px 24px;
    border-bottom: 1px solid rgba(0,0,0,.04);
    cursor: pointer;
    transition: all var(--transition);
}

.lesson-item:hover { background: #f1f5f9; }

/* Play icon states */
.lesson-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 2px solid var(--border);
    color: var(--text-muted);
    font-size: .65rem;
    transition: all var(--transition);
}

/* Default: grey */
.lesson-icon svg { width: 12px; height: 12px; }

/* Started (played): blue ring */
.lesson-item.played .lesson-icon {
    border-color: var(--primary);
    color: var(--primary);
}

/* Completed: blue filled */
.lesson-item.completed .lesson-icon {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Playing: accent filled */
.lesson-item.playing {
    background: linear-gradient(90deg, rgba(241,8,114,.08), rgba(241,8,114,.02));
}

.lesson-item.playing .lesson-icon {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    animation: pulse-icon 2s infinite;
}

@keyframes pulse-icon {
    0%, 100% { box-shadow: 0 0 0 0 rgba(241,8,114,.3); }
    50% { box-shadow: 0 0 0 6px rgba(241,8,114,0); }
}

.lesson-title {
    flex: 1;
    font-size: .85rem;
    line-height: 1.3;
    min-width: 0;
}

.lesson-item.playing .lesson-title { font-weight: 600; color: var(--accent); }

.lesson-time {
    font-size: .75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.lesson-progress-bar {
    width: 32px;
    height: 3px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
    flex-shrink: 0;
}

.lesson-progress-bar-fill {
    height: 100%;
    border-radius: 99px;
    background: var(--primary);
    transition: width .3s;
}

.lesson-item.playing .lesson-progress-bar-fill { background: var(--accent); }

/* Reset button */
.player-reset {
    padding: 16px;
    border-top: 1px solid var(--border);
    text-align: center;
}

/* --- COURSE DETAIL PAGE --- */
.course-hero {
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: #fff;
    padding: 48px 0;
}

.course-hero h1 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 16px;
}

.course-hero-desc {
    font-size: 1.05rem;
    color: rgba(255,255,255,.7);
    line-height: 1.6;
    max-width: 640px;
}

.course-hero-meta {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.course-hero-meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .9rem;
    color: rgba(255,255,255,.8);
}

.course-hero-meta-item svg { width: 18px; height: 18px; opacity: .6; }

.course-detail-body {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 32px;
    padding: 32px 0 64px;
}

.course-detail-main {}

.course-detail-sidebar {
    position: sticky;
    top: 96px;
    align-self: start;
}

.course-sidebar-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.course-sidebar-card-image {
    aspect-ratio: 16/10;
    overflow: hidden;
}

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

.course-sidebar-card-body { padding: 24px; }

/* --- EMPTY STATE --- */
.empty-state {
    text-align: center;
    padding: 80px 24px;
}

.empty-state svg {
    width: 80px;
    height: 80px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-light);
    max-width: 400px;
    margin: 0 auto;
}

.barc-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* line-clamp gestito per pagina */


.cat-hero{background:linear-gradient(135deg,#0f172a,#1e293b);color:#fff;padding:40px 0}
        .cat-hero-inner{display:flex;align-items:center;gap:20px}
        .cat-hero-icon{font-size:3rem;line-height:1}
        .cat-hero h1{font-size:2rem;font-weight:700;margin-bottom:4px}
        .cat-hero-sub{font-size:1rem;color:rgba(255,255,255,.6)}
        .cat-layout{display:grid;grid-template-columns:240px 1fr;gap:32px;padding:32px 0 64px}
        .cat-sidebar{position:sticky;top:88px;align-self:start;max-height:calc(100vh - 120px);overflow-y:auto}
        .cat-sidebar h4{font-size:.85rem;font-weight:700;color:var(--text-muted);text-transform:uppercase;letter-spacing:.5px;margin-bottom:12px}
        .cat-nav{list-style:none;padding:0;margin:0}
        .cat-nav li a{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;border-radius:var(--radius-sm);font-size:.88rem;color:var(--text);transition:all .15s;text-decoration:none}
        .cat-nav li a:hover{background:var(--bg);color:var(--primary)}
        .cat-nav li a.active{background:rgba(19,137,203,.08);color:var(--primary);font-weight:600}
        .cat-nav li a .cat-count{font-size:.75rem;color:var(--text-muted);background:var(--bg);padding:2px 8px;border-radius:99px}
        .cat-nav li a.active .cat-count{background:rgba(19,137,203,.15);color:var(--primary)}
        .cat-sort{display:flex;align-items:center;gap:12px;margin-bottom:20px}
        .cat-sort label{font-size:.85rem;color:var(--text-light);font-weight:500}
        .cat-sort select{padding:6px 12px;border:1px solid var(--border);border-radius:var(--radius-sm);font-size:.85rem;background:#fff;cursor:pointer}

        /* Wrapper immagine - come index.php */
        .course-card-img-wrap{position:relative;aspect-ratio:16/10;overflow:hidden;background:#e2e8f0}
        .course-card-img-wrap .course-card-image{display:block;width:100%;height:100%}
        .course-card-img-wrap img{width:100%;height:100%;object-fit:cover}

        /* Badge su immagine */
        .card-badges{position:absolute;top:10px;left:10px;right:10px;display:flex;justify-content:space-between;pointer-events:none;gap:6px;z-index:2}
        .card-badge-cat{display:inline-flex;align-items:center;gap:4px;background:rgba(0,0,0,.6);backdrop-filter:blur(6px);color:#fff;font-size:.68rem;font-weight:600;padding:4px 10px;border-radius:99px;text-decoration:none;pointer-events:auto;white-space:nowrap}
        .card-badge-cat:hover{background:var(--primary);color:#fff}
        .card-badge-premium{display:inline-flex;align-items:center;background:linear-gradient(135deg,#f59e0b,#f97316);color:#fff;font-size:.62rem;font-weight:700;padding:3px 9px;border-radius:99px;text-transform:uppercase;letter-spacing:.5px}

        /* Vista lista */
        .view-controls{display:flex;align-items:center;justify-content:space-between;margin-bottom:20px}
        .view-toggle{display:flex;gap:4px;background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius-sm);padding:3px}
        .view-btn{display:flex;align-items:center;justify-content:center;width:36px;height:32px;border:none;background:none;border-radius:6px;cursor:pointer;color:var(--text-muted);transition:all .2s}
        .view-btn:hover{color:var(--text-light);background:var(--bg)}
        .view-btn.active{background:var(--primary);color:#fff}
        .view-btn svg{width:16px;height:16px}
        .course-list-view{display:flex;flex-direction:column;gap:16px;padding-bottom:40px}
        .course-list-view .course-card{flex-direction:row}
        .course-list-view .course-card:hover{transform:none}
        .course-list-view .course-card-img-wrap{width:240px;min-height:160px;aspect-ratio:unset;flex-shrink:0}
        .course-list-view .course-card-img-wrap img{width:100%;height:100%;object-fit:cover}
        .course-list-view .course-card-body{padding:16px 20px}

        /* Link autore cliccabile */
        .course-card-author-link{color:var(--text);text-decoration:none;transition:color .2s}
        .course-card-author-link:hover{color:var(--primary);text-decoration:underline}

        /* ===== MOBILE NAVBAR ===== */
        .mobile-topbar{display:none}
        .mobile-search-bar{display:none}
        .mobile-menu-overlay{display:none}
        .mobile-menu-panel{display:none}

.search-count-mobile {
    position: absolute;
    right: 50px;
    top: 10%;
    transform: translateY(-50%);
    font-size: .75rem;
    color: var(--text-muted);
}


/* --- RESPONSIVE --- */
@media (max-width: 1024px) {
    .course-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
    .course-detail-body {
        grid-template-columns: 1fr;
    }
    .admin-sidebar { width: 220px; }
    .player-sidebar { width: 320px; }
}

@media (max-width: 768px) {
    .course-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .admin-layout { flex-direction: column; }
    .admin-sidebar { width: 100%; padding: 12px 0; }
    .admin-sidebar-nav { display: flex; overflow-x: auto; }
    .admin-sidebar-nav a { padding: 10px 16px; border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; }
    .admin-sidebar-nav a.active { border-bottom-color: var(--primary); }
    .admin-content { padding: 20px; }

    /* Player mobile: stili base - override dettagliati in player.php <style> */
    .player-wrapper { flex-direction: column; }
    .player-video-container { aspect-ratio: 16/9; flex: none; }
    .player-sidebar { width: 100%; }

    .stats-grid { grid-template-columns: 1fr 1fr; }

    .table-container { overflow-x: auto; }
    table { min-width: 600px; }

    .page-header h1 { font-size: 1.4rem; }
            /* Nascondi navbar desktop */
            .navbar .navbar-search{display:none!important}
            .navbar .navbar-user{display:none!important}

            /* Topbar mobile con hamburger */
            .mobile-topbar{display:flex;align-items:center;gap:12px;margin-left:auto}
            .mobile-topbar .mobile-search-toggle,
            .mobile-topbar .mobile-menu-toggle{
                display:flex;align-items:center;justify-content:center;
                width:38px;height:38px;border:none;background:none;
                color:var(--text);cursor:pointer;border-radius:var(--radius-sm)
            }
            
/* 
.mobile-topbar .mobile-search-toggle:hover,
.mobile-topbar .mobile-menu-toggle:hover{background:var(--bg)}
*/
            .mobile-topbar svg{width:22px;height:22px}

            /* Barra di ricerca mobile (sotto la navbar) */
            .mobile-search-bar{
                display:none;background:var(--bg-card);
                border-bottom:1px solid var(--border);padding:10px 16px
            }
            .mobile-search-bar.open{display:block}
            .mobile-search-bar input{
                width:100%;padding:10px 14px;border:1px solid var(--border);
                border-radius:var(--radius-sm);font-size:.9rem;background:#fff;
                outline:none
            }
            .mobile-search-bar input:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(19,137,203,.1)}

            /* Menu laterale slide-in */
            .mobile-menu-overlay{
                display:none;position:fixed;inset:0;background:rgba(0,0,0,.4);
                z-index:999;opacity:0;transition:opacity .25s
            }
            .mobile-menu-overlay.open{display:block;opacity:1}
            .mobile-menu-panel{
                display:flex;flex-direction:column;
                position:fixed;top:0;right:-280px;width:280px;height:100%;
                background:var(--bg-card);z-index:1000;
                transition:right .3s ease;box-shadow:-4px 0 20px rgba(0,0,0,.15);
                overflow-y:auto
            }
            .mobile-menu-panel.open{right:0}
            .mobile-menu-header{
                display:flex;align-items:center;justify-content:space-between;
                padding:16px 20px;border-bottom:1px solid var(--border)
            }
            .mobile-menu-header .mobile-user{display:flex;align-items:center;gap:10px}
            .mobile-menu-header .mobile-avatar{
                width:36px;height:36px;border-radius:50%;
                background:var(--primary);color:#fff;
                display:flex;align-items:center;justify-content:center;
                font-weight:700;font-size:.85rem
            }
            .mobile-menu-header .mobile-user-name{font-weight:600;font-size:.9rem}
            .mobile-menu-header .mobile-user-role{font-size:.75rem;color:var(--text-muted)}
            .mobile-menu-close{
                display:flex;align-items:center;justify-content:center;
                width:34px;height:34px;border:none;background:none;
                cursor:pointer;border-radius:var(--radius-sm);color:var(--text-muted)
            }
            .mobile-menu-close:hover{background:var(--bg)}
            .mobile-menu-close svg{width:20px;height:20px}
            .mobile-menu-links{padding:12px 16px;display:flex;flex-direction:column;gap:4px}
            .mobile-menu-links a{
                display:flex;align-items:center;gap:10px;
                padding:12px 14px;border-radius:var(--radius-sm);
                text-decoration:none;color:var(--text);font-size:.9rem;font-weight:500;
                transition:background .15s
            }
            .mobile-menu-links a:hover{background:var(--bg)}
            .mobile-menu-links a svg{width:18px;height:18px;color:var(--text-muted);flex-shrink:0}
            .mobile-menu-links a.danger{color:#ef4444}
            .mobile-menu-links a.danger svg{color:#ef4444}

            /* Hero mobile */
            .cat-hero{padding:24px 0}
            .cat-hero-icon{font-size:2rem}
            .cat-hero h1{font-size:1.4rem}

            /* Layout */
            .cat-layout{grid-template-columns:1fr;gap:20px;padding:20px 0 48px}
            .cat-sidebar{position:static;display:flex;flex-wrap:wrap;gap:6px;max-height:none}
            .cat-sidebar h4{width:100%}
            .cat-nav{display:flex;flex-wrap:wrap;gap:6px}
            .cat-nav li a{padding:6px 12px;font-size:.8rem;background:var(--bg);border-radius:99px}
            .cat-nav li a.active{background:rgba(19,137,203,.12)}

            /* View controls mobile: nascondi toggle vista, mostra solo sort */
            .view-toggle{display:none!important}
            .view-controls{flex-wrap:wrap;gap:10px}

            /* Forza griglia su mobile */
            .course-list-view{display:grid!important;grid-template-columns:repeat(auto-fill,minmax(260px,1fr))!important;gap:20px!important;flex-direction:unset!important}
            .course-list-view .course-card{flex-direction:column!important}
            .course-list-view .course-card-img-wrap{width:100%!important;min-height:unset!important;aspect-ratio:16/10!important}
            
.course-hero h1 {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 16px;
} 
            
        }

        @media(min-width:769px) and (max-width:1024px){
            .cat-layout{grid-template-columns:1fr}
            .cat-sidebar{position:static;display:flex;flex-wrap:wrap;gap:6px;max-height:none}
            .cat-sidebar h4{width:100%}
            .cat-nav{display:flex;flex-wrap:wrap;gap:6px}
            .cat-nav li a{padding:6px 12px;font-size:.8rem;background:var(--bg);border-radius:99px}
            .cat-nav li a.active{background:rgba(19,137,203,.12)}
            /* Lista ottimizzata tablet */
            .course-list-view .course-card-img-wrap{width:200px}
        }

@media (max-width: 480px) {
    .container { padding: 0 16px; }
    .navbar { padding: 0 16px; }
    .login-card { padding: 28px; }
    .stats-grid { grid-template-columns: 1fr; }
}