/* ========================================
   WRE EduPlatform - Modern UI
   ======================================== */

:root {
    --primary: #4263eb;
    --primary-light: #edf2ff;
    --success: #12b76a;
    --success-bg: #ecfdf3;
    --warning: #f79009;
    --warning-bg: #fffaeb;
    --danger: #f04438;
    --danger-bg: #fef3f2;
    --info: #0ba5ec;
    --info-bg: #ecfdff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --white: #ffffff;
    --sidebar-width: 280px;
    --sidebar-bg: #f8fafc;
    --sidebar-hover: #f1f5f9;
    --sidebar-active: #e0e7ff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--white);
    color: var(--gray-900);
    line-height: 1.5;
    font-size: 14px;
}

a {
    color: var(--primary);
    text-decoration: none;
}

/* ========================================
   Accessibility (WCAG 2.1)
   ======================================== */

.skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    border-radius: 0 0 8px 8px;
    z-index: 10000;
    font-weight: 600;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--warning);
    outline-offset: 2px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

a:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
    outline: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========================================
   Layout
   ======================================== */

.wrapper {
    display: flex;
    min-height: 100vh;
}

/* ========================================
   Sidebar
   ======================================== */

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--gray-200);
}

.sidebar-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.15s ease;
    border-bottom: 1px solid var(--gray-200);
    min-height: 73px;
}

.sidebar-header:hover {
    opacity: 0.85;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #4263eb 0%, #7c3aed 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 18px;
}

.sidebar-header h2,
.sidebar-header h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
    white-space: nowrap;
    max-width: 160px;
    line-height: 1.2;
}

/* Dynamiczny rozmiar tekstu logo */
.sidebar-header .logo-text {
    display: inline-block;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #4263eb 0%, #7c3aed 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
    overflow-y: auto;
}

.sidebar-section,
.nav-section {
    padding: 20px 12px 10px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--gray-500);
    letter-spacing: 0.5px;
    font-weight: 700;
}

.sidebar-nav a,
.sidebar-nav a.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: var(--gray-600);
    border-radius: 10px;
    transition: all 0.15s ease;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    text-decoration: none;
}

.sidebar-nav a:hover,
.sidebar-nav a.nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--gray-900);
}

.sidebar-nav a.active,
.sidebar-nav a.nav-link.active {
    background: var(--sidebar-active);
    color: var(--primary);
}

.nav-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--gray-500);
}

.sidebar-nav a:hover .nav-icon,
.sidebar-nav a.nav-link:hover .nav-icon {
    color: var(--gray-700);
}

.sidebar-nav a.active .nav-icon,
.sidebar-nav a.nav-link.active .nav-icon {
    color: var(--primary);
}

.nav-badge {
    margin-left: auto;
    background: var(--gray-200);
    color: var(--gray-600);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    min-width: 32px;
    text-align: center;
}

.sidebar-nav a.active .nav-badge {
    background: rgba(66, 99, 235, 0.15);
    color: var(--primary);
}

.nav-badge-warning {
    background: var(--warning-bg) !important;
    color: var(--warning) !important;
}

.sidebar-footer {
    padding: 16px;
    margin-top: auto;
    border-top: 1px solid var(--gray-200);
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 20px;
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
}

.btn-logout:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
    color: var(--gray-900);
}

.btn-logout span {
    font-size: 16px;
    color: var(--gray-500);
}

/* ========================================
   Main Content
   ======================================== */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--gray-50);
}

.top-bar {
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--gray-200);
    padding: 0 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 73px;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.top-bar-left h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 16px;
}

.content-area {
    padding: 28px 32px;
    flex: 1;
    background: var(--gray-50);
}

/* ========================================
   User Info & Avatar
   ======================================== */

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    aspect-ratio: 1;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    color: var(--white);
}

.avatar-blue { background: #4263eb; }
.avatar-green { background: #12b76a; }
.avatar-orange { background: #f79009; }
.avatar-red { background: #f04438; }
.avatar-purple { background: #7c3aed; }
.avatar-cyan { background: #0ba5ec; }
.avatar-pink { background: #ec4899; }
.avatar-yellow { background: #eab308; }

/* ========================================
   Page Header
   ======================================== */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
}

.page-subtitle {
    font-size: 14px;
    color: var(--gray-500);
    margin: 4px 0 0 0;
}

/* ========================================
   Stats Cards
   ======================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    padding: 20px 24px;
    border-radius: 12px;
    border: 1px solid var(--gray-200);
}

.stat-card h3 {
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-card.stat-primary { border-left: 4px solid var(--primary); }
.stat-card.stat-success { border-left: 4px solid var(--success); }
.stat-card.stat-warning { border-left: 4px solid var(--warning); }
.stat-card.stat-danger { border-left: 4px solid var(--danger); }
.stat-card.stat-info { border-left: 4px solid var(--info); }

/* ========================================
   Cards
   ======================================== */

.card {
    background: var(--white);
    border-radius: 16px;
    border: 1px solid var(--gray-200);
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

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

.card-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--gray-900);
}

.card-body {
    padding: 0;
}

.card-body.padded {
    padding: 28px;
}

/* ========================================
   Tables
   ======================================== */

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

.table th {
    padding: 14px 28px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.table td {
    padding: 18px 28px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.table tbody tr {
    transition: background 0.15s ease;
}

.table tbody tr:hover {
    background: var(--gray-50);
}

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

/* ========================================
   Badges / Status
   ======================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* Course status badges */
.badge-draft { background: var(--gray-100); color: var(--gray-600); }
.badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-published { background: var(--success-bg); color: var(--success); }
.badge-archived { background: var(--gray-100); color: var(--gray-500); }

/* Enrollment status badges */
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-completed { background: var(--primary-light); color: var(--primary); }
.badge-expired { background: var(--gray-100); color: var(--gray-500); }
.badge-cancelled { background: var(--danger-bg); color: var(--danger); }

/* Level badges */
.badge-beginner { background: var(--success-bg); color: var(--success); }
.badge-intermediate { background: var(--warning-bg); color: var(--warning); }
.badge-advanced { background: var(--danger-bg); color: var(--danger); }

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}

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

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #5a75f0 100%);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(66, 99, 235, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #3b5bdb 0%, #4c6ef5 100%);
    box-shadow: 0 4px 12px rgba(66, 99, 235, 0.4);
}

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

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #34d399 100%);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(18, 183, 106, 0.3);
}

.btn-success:hover {
    box-shadow: 0 4px 12px rgba(18, 183, 106, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(185, 28, 28, 0.3);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #991b1b 0%, #b91c1c 100%);
    box-shadow: 0 4px 12px rgba(185, 28, 28, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning) 0%, #fbbf24 100%);
    color: var(--white);
}

.btn-sm {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 8px;
    min-width: 38px;
    min-height: 38px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
}

.btn-icon {
    padding: 10px;
    border-radius: 6px;
}

.btn-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-group .btn {
    margin: 0;
}

.btn-group form {
    margin: 0;
    display: inline-flex;
}

/* ========================================
   Forms
   ======================================== */

.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--gray-700);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.15s ease;
    background: var(--white);
    color: var(--gray-900);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(66, 99, 235, 0.15);
}

.form-control:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.form-control::placeholder {
    color: var(--gray-400);
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

.form-help {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: var(--gray-500);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--gray-700);
    padding: 8px 0;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 2px solid var(--gray-300);
    cursor: pointer;
    accent-color: var(--primary);
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--gray-700);
    padding: 6px 0;
}

.radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.settings-grid h3 {
    margin: 0 0 20px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
}

.settings-column {
    min-width: 0;
}

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

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
}

.filter-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
}

.filter-row .filter-search {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
}

.filter-row .filter-options {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-row .form-group {
    margin-bottom: 0;
}

.filter-row .form-control {
    width: auto;
    min-width: 160px;
}

/* ========================================
   Alerts
   ======================================== */

.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: var(--success-bg);
    color: #067647;
    border: 1px solid #abefc6;
}

.alert-error {
    background: var(--danger-bg);
    color: #b42318;
    border: 1px solid #fecdca;
}

.alert-warning {
    background: var(--warning-bg);
    color: #b54708;
    border: 1px solid #fedf89;
}

.alert-info {
    background: var(--info-bg);
    color: #026aa2;
    border: 1px solid #b9e6fe;
}

/* ========================================
   Toast Notifications
   ======================================== */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 12px;
    background: white;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
    animation: toastSlideIn 0.3s ease-out;
    min-width: 280px;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-hiding {
    animation: toastSlideOut 0.3s ease-in forwards;
}

@keyframes toastSlideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-800);
}

.toast-close {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    transition: color 0.15s;
}

.toast-close:hover {
    color: var(--gray-600);
}

.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);
}

.toast-info {
    border-left: 4px solid var(--info);
}

.toast-info .toast-icon {
    color: var(--info);
}

/* ========================================
   Empty State
   ======================================== */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.empty-state > i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
    display: block;
}

.empty-state p {
    margin-bottom: 16px;
    font-size: 15px;
}

.empty-state .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    width: auto;
}

.empty-state .btn i {
    font-size: 14px;
    opacity: 1;
    margin-bottom: 0;
}

/* ========================================
   Course Cards
   ======================================== */

.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.course-card {
    background: var(--white);
    border-radius: 16px;
    border: 1px solid var(--gray-200);
    overflow: visible;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.course-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.course-thumbnail-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: 16px 16px 0 0;
}

.course-completed-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
    display: flex;
    align-items: center;
    gap: 6px;
}

.course-completed-badge i {
    font-size: 11px;
}

.course-thumbnail {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
}

.course-thumbnail-placeholder {
    width: 100%;
    height: 180px;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 48px;
}

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

.course-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 8px;
    line-height: 1.4;
}

.course-card-title a {
    color: inherit;
    text-decoration: none;
}

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

.course-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--gray-500);
    font-size: 13px;
    margin-bottom: 12px;
}

.course-card-meta i {
    margin-right: 4px;
}

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

.course-progress {
    width: 100%;
    margin-top: 12px;
}

.progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, #7c3aed 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 6px;
    text-align: right;
}

/* ========================================
   Lesson Player
   ======================================== */

.lesson-layout {
    display: flex;
    min-height: 100vh;
    background: #f8fafc;
}

.lesson-layout .lesson-sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
}

.lesson-layout .sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 72px;
    box-sizing: border-box;
}

.lesson-layout .back-link {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border-radius: 8px;
    color: var(--gray-600);
    text-decoration: none;
    transition: all 0.15s;
}

.lesson-layout .back-link:hover {
    background: var(--gray-200);
    color: var(--gray-900);
}

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

.lesson-layout .course-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    display: block;
    margin-bottom: 2px;
}

.lesson-layout .sidebar-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lesson-layout .lesson-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.lesson-layout .lesson-section-header {
    padding: 20px 24px 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
}

.lesson-layout .lesson-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--gray-600);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s;
    margin: 2px 0;
    border-left: 3px solid transparent;
}

.lesson-layout .lesson-item:hover {
    background: var(--gray-50);
    color: var(--gray-900);
}

.lesson-layout .lesson-item.active {
    background: var(--primary-bg, #eef2ff);
    color: var(--primary);
    font-weight: 500;
    border-left-color: var(--primary);
}

.lesson-layout .lesson-item.completed i {
    color: var(--success);
}

.lesson-layout .lesson-item.active i {
    color: var(--primary);
}

.lesson-layout .lesson-item i {
    font-size: 12px;
    width: 16px;
    text-align: center;
}

.lesson-layout .lesson-item span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lesson-layout .lesson-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.lesson-layout .lesson-topbar {
    background: #fff;
    padding: 16px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 72px;
    box-sizing: border-box;
}

.lesson-layout .lesson-topbar-info {
    flex: 1;
}

.lesson-layout .section-name {
    font-size: 12px;
    color: #64748b;
    display: block;
    margin-bottom: 2px;
}

.lesson-layout .lesson-topbar h1 {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.lesson-layout .lesson-content-wrapper {
    flex: 1;
    padding: 24px 48px;
    overflow-y: auto;
}

.lesson-layout .lesson-content {
    background: var(--white);
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 32px;
    margin-bottom: 24px;
    max-width: 1400px;
}

.lesson-layout .lesson-text-content {
    font-size: 15px;
    line-height: 1.7;
    color: #334155;
}

.lesson-layout .lesson-text-content h2:not([style*="color"]) {
    font-size: 22px;
    font-weight: 700;
    color: #1e293b;
    margin: 24px 0 12px 0;
}

.lesson-layout .lesson-text-content h3:not([style*="color"]) {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    margin: 20px 0 10px 0;
}

.lesson-layout .lesson-text-content p {
    margin-bottom: 14px;
}

.lesson-layout .lesson-text-content ul,
.lesson-layout .lesson-text-content ol {
    margin-bottom: 16px;
    padding-left: 20px;
}

.lesson-layout .lesson-text-content li {
    margin-bottom: 8px;
}

.lesson-layout .lesson-text-content code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 13px;
}

.lesson-layout .lesson-text-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 16px 0;
    font-size: 13px;
}

.lesson-layout .lesson-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px 24px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
}

.lesson-layout .video-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}

.lesson-layout .video-container iframe,
.lesson-layout .video-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Responsywność */
@media (max-width: 1024px) {
    .lesson-layout .lesson-content-wrapper {
        padding: 20px;
    }
    
    .lesson-layout .lesson-content {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .lesson-layout {
        flex-direction: column;
    }
    
    .lesson-layout .lesson-sidebar {
        width: 100%;
        min-width: auto;
        height: auto;
        position: relative;
    }
    
    .lesson-layout .lesson-list {
        max-height: 200px;
    }
    
    .lesson-layout .lesson-content-wrapper {
        padding: 16px;
    }
    
    .lesson-layout .lesson-content {
        padding: 16px;
    }
    
    .lesson-layout .lesson-topbar h1 {
        font-size: 24px;
    }
    
    .lesson-layout .lesson-actions {
        flex-direction: column;
    }
}

.lesson-section {
    border-bottom: 1px solid var(--gray-100);
}

.lesson-section-header {
    padding: 16px 20px;
    font-weight: 600;
    font-size: 14px;
    background: var(--gray-50);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lesson-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: var(--gray-600);
    text-decoration: none;
    transition: background 0.15s;
    border-bottom: 1px solid var(--gray-50);
}

.lesson-item:hover {
    background: var(--gray-50);
}

.lesson-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

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

.lesson-item-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    font-size: 12px;
    flex-shrink: 0;
}

.lesson-item.completed .lesson-item-icon {
    background: var(--success);
    color: white;
}

.lesson-item.active .lesson-item-icon {
    background: var(--primary);
    color: white;
}

.lesson-item-title {
    flex: 1;
    font-size: 14px;
}

.lesson-item-duration {
    font-size: 12px;
    color: var(--gray-400);
}

.lesson-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
}

/* ========================================
   Quiz Styles
   ======================================== */

.quiz-container {
    max-width: 800px;
    margin: 0 auto;
}

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

.quiz-title {
    font-size: 28px;
    margin-bottom: 8px;
}

.quiz-info {
    display: flex;
    justify-content: center;
    gap: 24px;
    color: var(--gray-500);
}

.quiz-timer {
    position: fixed;
    top: 100px;
    right: 32px;
    background: var(--white);
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    font-size: 18px;
    font-weight: 600;
}

.quiz-timer.warning {
    color: var(--danger);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.quiz-question {
    background: var(--white);
    border-radius: 16px;
    border: 1px solid var(--gray-200);
    padding: 28px;
    margin-bottom: 24px;
}

.quiz-question-number {
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.quiz-question-text {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 24px;
    line-height: 1.5;
}

.quiz-answers {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quiz-answer {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.quiz-answer:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.quiz-answer.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.quiz-answer.correct {
    border-color: var(--success);
    background: var(--success-bg);
}

.quiz-answer.incorrect {
    border-color: var(--danger);
    background: var(--danger-bg);
}

.quiz-answer-marker {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--gray-300);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.quiz-answer.selected .quiz-answer-marker {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.quiz-result {
    text-align: center;
    padding: 48px;
}

.quiz-result-score {
    font-size: 64px;
    font-weight: 700;
    margin-bottom: 16px;
}

.quiz-result-score.passed {
    color: var(--success);
}

.quiz-result-score.failed {
    color: var(--danger);
}

.quiz-result-message {
    font-size: 18px;
    margin-bottom: 32px;
}

/* ========================================
   User Dropdown
   ======================================== */

.user-dropdown {
    position: relative;
}

.user-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.user-dropdown-toggle:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.user-name {
    font-weight: 500;
    color: #374151;
}

.dropdown-arrow {
    font-size: 10px;
    color: #6b7280;
    transition: transform 0.2s;
}

.user-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    min-width: 240px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.user-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.dropdown-header strong {
    display: block;
    color: #111827;
    margin-bottom: 2px;
}

.dropdown-header span {
    font-size: 13px;
    color: #6b7280;
    display: block;
}

.role-badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 8px;
}

.role-badge.role-teacher {
    background: var(--success-bg);
    color: var(--success);
}

.role-badge.role-student {
    background: #f3e8ff;
    color: #7c3aed;
}

.dropdown-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 4px 0;
}

/* Dropdown ogólny */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    z-index: 1000;
    display: none;
    padding: 8px 0;
    margin-top: 4px;
}

.dropdown-menu-right {
    right: 0;
    left: auto;
}

.dropdown.active .dropdown-menu,
.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: #374151;
    text-decoration: none;
    transition: background 0.15s;
}

.dropdown-item:hover {
    background: #f3f4f6;
}

.dropdown-item i {
    width: 16px;
    text-align: center;
}

.text-danger {
    color: var(--danger) !important;
}

.dropdown-item.text-danger:hover {
    background: var(--danger-bg);
}

/* ========================================
   Login Page
   ======================================== */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e1e2d 0%, #2d2d44 100%);
    padding: 20px;
}

.login-box {
    background: var(--white);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 420px;
}

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

.login-logo .logo-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #4263eb 0%, #7c3aed 100%);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 24px;
    margin-bottom: 16px;
}

.login-logo h1 {
    font-size: 24px;
    color: var(--gray-900);
    font-weight: 600;
}

.login-logo p {
    color: var(--gray-500);
    margin-top: 4px;
}

/* ========================================
   Modal
   ======================================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

.modal.show,
.modal.active {
    display: block;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
}

.modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.25);
    z-index: 1002;
}

.modal-content.modal-lg {
    max-width: 720px;
}

.modal-content.modal-xl {
    max-width: 900px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 28px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
    border-radius: 16px 16px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-500);
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.modal-close:hover {
    color: var(--gray-900);
    background: var(--gray-200);
}

.modal-body {
    padding: 28px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 20px 28px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    border-radius: 0 0 16px 16px;
}

/* ========================================
   Grid Layout
   ======================================== */

.row {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
}

.row.mb-3 {
    margin-bottom: 24px;
}

.col-4 { flex: 1 1 250px; max-width: 33.333%; }
.col-6 { flex: 1 1 300px; max-width: 50%; }
.col-8 { flex: 2 1 400px; max-width: 66.666%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

/* Utility classes */
.mt-3 { margin-top: 24px; }
.mb-3 { margin-bottom: 24px; }
.mb-0 { margin-bottom: 0; }

@media (max-width: 992px) {
    .col-4, .col-6, .col-8 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ========================================
   Responsive
   ======================================== */

.mobile-menu-toggle {
    display: none;
}

.sidebar-overlay {
    display: none;
}

@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .lesson-layout {
        grid-template-columns: 1fr;
    }
    
    .lesson-sidebar {
        position: static;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1000;
        transition: transform 0.3s ease;
    }
    
    .mobile-menu-open .sidebar {
        transform: translateX(0);
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .mobile-menu-open .sidebar-overlay {
        display: block;
        opacity: 1;
    }
    
    .mobile-menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        width: 36px;
        height: 36px;
        padding: 8px;
        background: var(--gray-100);
        border: none;
        border-radius: 8px;
        cursor: pointer;
        margin-right: 12px;
        transition: background 0.2s ease;
    }
    
    .mobile-menu-toggle:hover {
        background: var(--gray-200);
    }
    
    .mobile-menu-toggle span {
        display: block;
        width: 100%;
        height: 2px;
        background: var(--gray-600);
        border-radius: 2px;
        transition: all 0.3s ease;
    }
    
    .mobile-menu-open .mobile-menu-toggle span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .mobile-menu-open .mobile-menu-toggle span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-open .mobile-menu-toggle span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .top-bar {
        padding: 16px 20px;
    }
    
    .content-area {
        padding: 20px;
    }
    
    .user-name {
        display: none;
    }
    
    .dropdown-arrow {
        display: none;
    }
    
    .course-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .quiz-timer {
        position: static;
        margin-bottom: 24px;
        text-align: center;
    }
}

/* ========================================
   Utilities
   ======================================== */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 8px !important; }
.mb-2 { margin-bottom: 16px !important; }
.mb-3 { margin-bottom: 24px !important; }
.mb-4 { margin-bottom: 32px !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 8px !important; }
.mt-2 { margin-top: 16px !important; }
.mt-3 { margin-top: 24px !important; }
.mt-4 { margin-top: 32px !important; }

.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

.w-100 { width: 100%; }

/* ========================================
   Ukrycie głównego sidebara (dla lekcji)
   ======================================== */
.hide-main-sidebar .sidebar {
    display: none !important;
}
.hide-main-sidebar .main-content {
    margin-left: 0 !important;
}
.hide-main-sidebar .top-bar {
    display: none !important;
}
.hide-main-sidebar .content-area {
    padding: 0;
    max-width: none;
}

/* ========================================
   Toast Notifications
   ======================================== */
.toast-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 20px;
    border-radius: 10px;
    background: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    animation: toastSlideIn 0.3s ease;
    max-width: 400px;
}

.toast-notification.hiding {
    animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast-notification i {
    font-size: 18px;
    flex-shrink: 0;
}

.toast-notification span {
    flex: 1;
    font-size: 14px;
}

.toast-notification button {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--gray-400);
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.toast-notification button:hover {
    color: var(--gray-600);
}

.toast-info {
    border-left: 4px solid var(--primary);
}

.toast-info i {
    color: var(--primary);
}

.toast-success {
    border-left: 4px solid #10b981;
}

.toast-success i {
    color: #10b981;
}

.toast-error {
    border-left: 4px solid #ef4444;
}

.toast-error i {
    color: #ef4444;
}

.toast-warning {
    border-left: 4px solid #f59e0b;
}

.toast-warning i {
    color: #f59e0b;
}

