/* ================================================
   Platforma Szkoleniowa AI – Main Stylesheet
   ================================================ */

:root {
    --primary:     #4f46e5;
    --primary-dark:#3730a3;
    --cyan:        #0891b2;
    --green:       #059669;
    --orange:      #d97706;
    --red:         #dc2626;
    --sidebar-w:   260px;
    --sidebar-bg:  #1e1b4b;
    --topbar-h:    60px;
    --radius:      12px;
    --shadow:      0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.05);
}

* { box-sizing: border-box; }

body { font-family: 'Segoe UI', system-ui, sans-serif; background: #f1f5f9; color: #1e293b; }

/* ── CARDS ──────────────────────────────────────── */
.card {
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background: #fff;
}
.card-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: .75rem 1.25rem;
    font-weight: 600;
    border-radius: var(--radius) var(--radius) 0 0 !important;
}
.card-footer {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    border-radius: 0 0 var(--radius) var(--radius) !important;
}

/* ── LOGIN PAGE ─────────────────────────────────── */
.login-page {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e1b4b 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-wrapper { width: 100%; max-width: 420px; padding: 1rem; }
.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px rgba(0,0,0,.25);
}
.login-logo {
    font-size: 3rem;
    text-align: center;
    color: var(--primary);
    margin-bottom: 1rem;
}
.login-title { text-align: center; font-weight: 700; font-size: 1.5rem; margin-bottom: .25rem; }
.login-subtitle { text-align: center; color: #64748b; margin-bottom: 2rem; }

/* ── ADMIN LAYOUT ───────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: #c7d2fe;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transition: width .2s;
    overflow: hidden;
}
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .sidebar-user span { display: none; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1rem;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.1);
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-brand i { font-size: 1.5rem; color: #a5b4fc; flex-shrink: 0; }

.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 1rem;
    color: #a5b4fc;
    text-decoration: none;
    border-radius: 8px;
    margin: 2px 8px;
    transition: all .15s;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-link i { font-size: 1.1rem; flex-shrink: 0; }
.sidebar-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-link.active { background: var(--primary); color: #fff; }

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,.1);
    padding: .75rem 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.sidebar-user { display: flex; align-items: center; gap: .5rem; flex: 1; overflow: hidden; white-space: nowrap; font-size: .85rem; }
.sidebar-logout { color: #a5b4fc; text-decoration: none; font-size: 1.2rem; flex-shrink: 0; transition: color .15s; }
.sidebar-logout:hover { color: #fff; }

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left .2s;
}
.sidebar.collapsed ~ .main-content { margin-left: 64px; }

.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.topbar-title { font-weight: 600; color: #1e293b; }
.sidebar-toggle { padding: .25rem .5rem; color: #64748b; }

.content-area { padding: 1.5rem; flex: 1; }

/* ── STAT CARDS ─────────────────────────────────── */
.stat-card {
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .25rem;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    right: -20px; top: -20px;
    width: 80px; height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
}
.stat-blue   { background: linear-gradient(135deg, #4f46e5, #6366f1); color: #fff; }
.stat-cyan   { background: linear-gradient(135deg, #0891b2, #06b6d4); color: #fff; }
.stat-green  { background: linear-gradient(135deg, #059669, #10b981); color: #fff; }
.stat-orange { background: linear-gradient(135deg, #d97706, #f59e0b); color: #fff; }
.stat-icon   { font-size: 1.5rem; opacity: .8; }
.stat-value  { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-label  { font-size: .8rem; opacity: .85; }

/* ── PARTICIPANT LAYOUT ─────────────────────────── */
.participant-layout { background: #f1f5f9; }

.participant-navbar {
    background: var(--primary);
    padding: .75rem 0;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.participant-navbar .navbar-brand { color: #fff; font-weight: 700; }
.participant-navbar .nav-link { color: rgba(255,255,255,.8); }
.participant-navbar .nav-link:hover,
.participant-navbar .nav-link.active { color: #fff; }
.participant-navbar .navbar-toggler-icon { filter: invert(1); }

/* ── MODULE CARDS ───────────────────────────────── */
.module-card-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem;
    border-bottom: 1px solid #e2e8f0;
}
.module-icon-lg {
    width: 48px; height: 48px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.module-icon { display: inline-flex; }

/* ── LESSON LIST ────────────────────────────────── */
.lesson-list { display: flex; flex-direction: column; gap: .5rem; }

.lesson-row {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: .75rem 1rem;
    border-radius: var(--radius);
    background: #fff;
    border: 1px solid #e2e8f0;
    transition: box-shadow .15s;
}
.lesson-row:hover { box-shadow: var(--shadow); }
.lesson-row.break-row { background: #f8fafc; border-style: dashed; }
.lesson-row.lesson-done { border-color: #bbf7d0; background: #f0fdf4; }

.lesson-time {
    min-width: 70px;
    text-align: center;
    flex-shrink: 0;
}
.lesson-action { flex-shrink: 0; }

/* ── TRAINING TIMELINE ──────────────────────────── */
.training-timeline { padding: 1.5rem; }
.timeline-item { display: flex; gap: 1rem; margin-bottom: 0; }
.timeline-time {
    width: 70px;
    text-align: right;
    flex-shrink: 0;
    padding-top: .5rem;
}
.time-start { font-weight: 700; color: var(--primary); font-size: .9rem; }
.time-duration { font-size: .75rem; color: #94a3b8; }

.timeline-connector { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.timeline-dot {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem; font-weight: 700;
    flex-shrink: 0;
}
.dot-lesson { background: var(--primary); color: #fff; }
.dot-break  { background: #e2e8f0; color: #64748b; font-size: .9rem; }
.timeline-line { width: 2px; flex: 1; background: #e2e8f0; min-height: 24px; }

.timeline-content { flex: 1; padding-bottom: 1.5rem; }
.timeline-card { padding: .75rem 1rem; border-radius: var(--radius); }
.lesson-card { background: #fff; border: 1px solid #e2e8f0; box-shadow: var(--shadow); }
.break-card  { background: #f8fafc; border: 1px dashed #cbd5e1; }
.lesson-header { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; margin-bottom: .25rem; }
.lesson-title { font-size: 1rem; font-weight: 600; margin: 0; }
.lesson-desc  { line-height: 1.5; }
.break-label  { font-size: .9rem; color: #64748b; font-style: italic; }

/* ── MATERIAL & TASK CARDS ──────────────────────── */
.material-card { transition: border-color .2s; }
.material-content {
    font-size: .95rem;
    line-height: 1.7;
    max-height: 600px;
    overflow-y: auto;
}
.task-card { transition: border-color .2s; }
.quiz-question { border-radius: 10px; }

/* ── LESSON STEPPER ─────────────────────────────── */
.lesson-stepper {
    display: flex;
    align-items: center;
    gap: 0;
    overflow-x: auto;
    padding-bottom: 4px;
}
.lesson-step {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: .8rem;
    font-weight: 700;
    flex-shrink: 0;
    text-decoration: none;
    transition: transform .15s, box-shadow .15s;
    border: 2px solid transparent;
}
.lesson-step:hover { transform: scale(1.15); box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.step-done    { background: #059669; color: #fff; border-color: #059669; }
.step-active  { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.25); }
.step-partial { background: #fff; color: #d97706; border-color: #d97706; }
.step-todo    { background: #fff; color: #94a3b8; border-color: #cbd5e1; }

.step-line {
    flex: 1;
    height: 2px;
    background: #cbd5e1;
    min-width: 12px;
    max-width: 48px;
}
.step-line-done { background: #059669; }

/* ── LESSON NAVIGATION ──────────────────────────── */
.lesson-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
    margin-top: 1rem;
}
.lesson-nav > div:last-child { text-align: right; }

/* ── MISC ───────────────────────────────────────── */
.badge.bg-primary-subtle  { background: #ede9fe !important; }
.badge.bg-success-subtle  { background: #dcfce7 !important; }
.badge.bg-secondary-subtle{ background: #f1f5f9 !important; }

.wave { display: inline-block; animation: wave 1s ease-in-out; }
@keyframes wave { 0%,100%{transform:rotate(0)} 25%{transform:rotate(20deg)} 75%{transform:rotate(-10deg)} }

/* ── SEPARATOR SLAJDU W EDYTORZE ───────────────── */
.ql-editor .slide-break {
    display: flex !important;
    align-items: center;
    gap: 10px;
    margin: 10px 0 !important;
    padding: 2px 0 !important;
    cursor: default;
    user-select: none;
    line-height: 1 !important;
}
/* Linie przerywane (fizyczne elementy DOM) */
.ql-editor .slide-break .sb-line {
    flex: 1;
    display: inline-block;
    height: 2px;
    background: repeating-linear-gradient(
        90deg,
        #6366f1 0px, #6366f1 7px,
        #c7d2fe 7px, #c7d2fe 13px
    );
    border-radius: 2px;
    vertical-align: middle;
}
/* Etykieta */
.ql-editor .slide-break .sb-label {
    flex-shrink: 0;
    background: #ede9fe;
    color: #4f46e5;
    font-size: .7rem;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 20px;
    white-space: nowrap;
    letter-spacing: .05em;
    border: 1.5px solid #c7d2fe;
    line-height: 1.6;
    display: inline-block;
}

/* Ukryj separator w normalnym widoku uczestnika */
.ql-rendered .slide-break { display: none !important; }

/* ── PODGLĄD MATERIAŁU (admin) ──────────────────── */
.preview-material-body {
    font-size: 1rem;
    line-height: 1.75;
    color: #1e293b;
    max-width: 780px;
    margin: 0 auto;
}
.preview-material-body p  { margin-bottom: .6rem; }
.preview-material-body h2 { font-size: 1.25rem; font-weight: 700; margin: 1.2rem 0 .4rem; }
.preview-material-body h3 { font-size: 1.05rem; font-weight: 600; margin: 1rem 0 .3rem; }
.preview-material-body ul,
.preview-material-body ol { padding-left: 1.6rem; margin-bottom: .6rem; }
.preview-material-body li { margin-bottom: .2rem; }

/* ── QUILL EDITOR ───────────────────────────────── */
.quill-editor-box {
    border: 1px solid #dee2e6;
    border-radius: 0 0 6px 6px;
    background: #fff;
    min-height: 140px;
}
.quill-editor-box .ql-editor {
    min-height: 120px;
    max-height: 380px;
    overflow-y: auto;
    font-size: .95rem;
    font-family: 'Segoe UI', system-ui, sans-serif;
}
.ql-toolbar.ql-snow {
    border-radius: 6px 6px 0 0;
    border-color: #dee2e6 !important;
    background: #f8fafc;
}
.ql-container.ql-snow {
    border-color: #dee2e6 !important;
    border-radius: 0 0 6px 6px;
}

/* ── QUILL RENDERED CONTENT ─────────────────────── */
/* Obsługuje HTML z Quilla i stary plain text */

.ql-rendered {
    line-height: 1.6;
    word-break: break-word;
}

/* Paragraf: zeruj domyślny duży margines przeglądarki */
.ql-rendered p {
    margin-top: 0;
    margin-bottom: 0.3rem;
}
.ql-rendered p:last-child {
    margin-bottom: 0;
}

/* Listy */
.ql-rendered ul,
.ql-rendered ol {
    padding-left: 1.4rem;
    margin-top: 0;
    margin-bottom: 0.3rem;
}
.ql-rendered li {
    margin-bottom: 0.1rem;
}

/* Nagłówki */
.ql-rendered h2 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0.5rem 0 0.2rem;
}
.ql-rendered h3 {
    font-size: .95rem;
    font-weight: 600;
    margin: 0.4rem 0 0.2rem;
}

/* Formatowanie inline */
.ql-rendered strong { font-weight: 600; }
.ql-rendered em     { font-style: italic; }
.ql-rendered u      { text-decoration: underline; }
.ql-rendered s      { text-decoration: line-through; }
.ql-rendered a      { color: var(--primary); }

/* Cytat / przykład */
.ql-rendered blockquote {
    border-left: 4px solid var(--primary);
    background: #f5f3ff;
    margin: .5rem 0;
    padding: .6rem 1rem;
    border-radius: 0 8px 8px 0;
    color: #374151;
    font-style: normal;
}

/* Blok kodu */
.ql-rendered pre,
.ql-rendered pre.ql-syntax {
    background: #1e1b4b;
    color: #e0e7ff;
    padding: .75rem 1rem;
    border-radius: 8px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: .85rem;
    line-height: 1.65;
    overflow-x: auto;
    margin: .4rem 0;
    white-space: pre-wrap;
}

/* Wcięcia (Quill) */
.ql-rendered .ql-indent-1 { padding-left: 2rem; }
.ql-rendered .ql-indent-2 { padding-left: 4rem; }
.ql-rendered .ql-indent-3 { padding-left: 6rem; }

/* Kompaktowy wariant (np. plan szkolenia) */
.lesson-desc.ql-rendered {
    line-height: 1.5;
}
.lesson-desc.ql-rendered p {
    margin-bottom: 0.15rem;
}
.lesson-desc.ql-rendered ul,
.lesson-desc.ql-rendered ol {
    margin-bottom: 0.15rem;
}

/* ── QUILL TABLE PICKER ─────────────────────────── */
.ql-table-picker {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,.13);
    padding: 10px 12px 12px;
    user-select: none;
}
.ql-table-picker-label {
    text-align: center;
    font-size: .75rem;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 8px;
    min-height: 1.1em;
    white-space: nowrap;
}
.ql-table-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 20px);
    gap: 3px;
}
.ql-table-picker-cell {
    width: 20px;
    height: 20px;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    background: #f8fafc;
    cursor: pointer;
    transition: background .08s, border-color .08s;
}
.ql-table-picker-cell.active,
.ql-table-picker-cell:hover {
    background: #ede9fe;
    border-color: var(--primary);
}

/* Ikona tabeli w pasku Quilla */
.ql-table-insert svg {
    width: 18px;
    height: 18px;
    vertical-align: middle;
}

/* ── TABELE W TREŚCI QUILL (widok uczestnika) ────── */
.ql-rendered table {
    border-collapse: collapse;
    width: 100%;
    margin: .75rem 0;
    font-size: .9rem;
    max-width: 100%;
}
.ql-rendered table td,
.ql-rendered table th {
    border: 1px solid #cbd5e1;
    padding: .45rem .75rem;
    vertical-align: top;
    text-align: left;
    min-width: 60px;
    word-break: break-word;
}
.ql-rendered table th,
.ql-rendered table tr:first-child td {
    background: #f1f5f9;
    font-weight: 600;
    color: #1e293b;
}
.ql-rendered table tr:nth-child(even) td {
    background: #f8fafc;
}
.ql-rendered table tr:hover td {
    background: #f0f4ff;
    transition: background .12s;
}
/* Akapity wewnątrz komórek (quill-better-table) */
.ql-rendered table td p,
.ql-rendered .qlbt-cell-line {
    margin: 0;
}

/* Ciągła numeracja list <ol> w edytorze – inline style z JS mogą być nadpisane,
   więc użyj [style] selektora żeby mieć wyższy priorytet niż Quill's CSS */
.ql-editor ol[style] {
    counter-reset: unset; /* usuń zewnętrzne resety */
}
/* Quill używa wewnętrznego licznika list-0; nasz inline counterReset go nadpisuje */

/* Tabela w edytorze admina – widok podglądu (nieedytowalna inline) */
.ql-editor table {
    border-collapse: collapse;
    width: 100%;
    margin: .5rem 0;
    cursor: pointer;
    user-select: none;
}
.ql-editor table:hover {
    outline: 2px dashed #6366f1;
    outline-offset: 3px;
}
.ql-editor table::after {
    content: '✎ edytuj (dwuklik)';
    display: none;
}
.ql-editor table:hover::after {
    display: block;
    text-align: right;
    font-size: .7rem;
    color: #6366f1;
    padding: 2px 4px 0;
}
.ql-editor table td {
    border: 1px solid #94a3b8;
    padding: .35rem .6rem;
    min-width: 80px;
    vertical-align: top;
}
.ql-editor table tr:first-child td {
    background: #f1f5f9;
    font-weight: 600;
}

/* Tabela w modalu edycji */
#ql-table-edit-wrap table {
    border-collapse: collapse;
    width: 100%;
}
#ql-table-edit-wrap td,
#ql-table-edit-wrap th {
    border: 1px solid #94a3b8;
    padding: .4rem .6rem;
    min-width: 90px;
    vertical-align: top;
    cursor: text;
}
#ql-table-edit-wrap tr:first-child td,
#ql-table-edit-wrap th {
    background: #f1f5f9;
    font-weight: 600;
}
#ql-table-edit-wrap td:focus,
#ql-table-edit-wrap th:focus {
    outline: 2px solid #6366f1;
    outline-offset: -2px;
    background: #f5f3ff !important;
}

/* ── CONFIRM MODAL ──────────────────────────────── */
#confirmModal .modal-content {
    border-radius: 16px;
}
#confirmModal .confirm-icon {
    animation: shake .4s ease;
}
@keyframes shake {
    0%,100% { transform: rotate(0); }
    25%      { transform: rotate(-8deg); }
    75%      { transform: rotate(8deg); }
}

/* ── TRAININGS ──────────────────────────────────── */
.training-icon {
    width: 48px; height: 48px;
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    color: #fff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.training-card { transition: box-shadow .15s; }
.training-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); }

.training-header {
    padding: .75rem 1rem;
    background: linear-gradient(90deg, #ede9fe 0%, #f8fafc 100%);
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
}

/* ── RESPONSIVE ─────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { width: 64px; }
    .sidebar .sidebar-brand span, .sidebar .sidebar-link span, .sidebar .sidebar-user span { display: none; }
    .main-content { margin-left: 64px; }
    .content-area { padding: 1rem; }
    .lesson-row { flex-wrap: wrap; }
    .timeline-time { width: 50px; }
}
