/* ============================
   LIZIU DSA - Tutorial Layout
   Sidebar + Main content grid, TOC, step-lists, complexity tables
   ============================ */

/* ---- Tutorial Hero ---- */
.tutorial-hero {
    background: var(--primary-gradient);
    color: var(--white);
    padding: var(--sp-12) 0 var(--sp-10);
    position: relative;
    overflow: hidden;
}

.tutorial-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.06'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

.tutorial-hero .container {
    position: relative;
    z-index: 1;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--text-sm);
    margin-bottom: var(--sp-4);
    opacity: 0.9;
}

.breadcrumb a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: color var(--transition);
}

.breadcrumb a:hover {
    color: var(--white);
}

.breadcrumb .separator {
    color: rgba(255, 255, 255, 0.5);
    font-size: var(--text-xs);
}

.breadcrumb .current {
    color: var(--white);
    font-weight: 500;
}

/* Hero title */
.tutorial-hero h1 {
    color: var(--white);
    margin-bottom: var(--sp-4);
}

.tutorial-hero .subtitle {
    font-size: var(--text-lg);
    opacity: 0.9;
    margin-bottom: var(--sp-5);
    max-width: 700px;
    line-height: 1.5;
    color: var(--white);
}

/* Meta info bar */
.tutorial-meta {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    flex-wrap: wrap;
}

.tutorial-meta .meta-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--text-sm);
    background: rgba(255, 255, 255, 0.15);
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--radius-full);
    backdrop-filter: blur(8px);
}

/* Top progress bar */
.tutorial-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--primary-gradient);
    z-index: calc(var(--z-nav) + 1);
    transition: width 100ms linear;
}

/* ---- Tutorial Layout Grid ---- */
.tutorial-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: var(--sp-10);
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--sp-8) var(--sp-6);
    align-items: start;
}

/* ---- Sidebar ---- */
.tutorial-sidebar {
    position: sticky;
    top: calc(var(--sp-8) + 60px); /* offset for nav height */
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding-right: var(--sp-4);
}

/* Scrollbar for sidebar */
.tutorial-sidebar::-webkit-scrollbar {
    width: 3px;
}

.tutorial-sidebar::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

/* Table of Contents */
.toc {
    margin-bottom: var(--sp-6);
}

.toc-title {
    font-size: var(--text-sm);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: var(--sp-3);
}

.toc-list {
    border-left: 2px solid var(--gray-200);
}

.toc-item {
    position: relative;
}

.toc-link {
    display: block;
    padding: var(--sp-2) var(--sp-4);
    font-size: var(--text-sm);
    color: var(--gray-500);
    text-decoration: none;
    border-left: 2px solid transparent;
    margin-left: -2px;
    transition: all var(--transition);
    line-height: 1.4;
}

.toc-link:hover {
    color: var(--gray-700);
}

.toc-link.active {
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 500;
    background: var(--primary-50);
}

/* Sub-items */
.toc-link[data-level="3"] {
    padding-left: var(--sp-8);
    font-size: 0.78rem;
}

/* Section completion */
.sidebar-sections {
    margin-bottom: var(--sp-6);
}

.sidebar-section-check {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) 0;
    font-size: var(--text-sm);
    color: var(--gray-600);
    cursor: pointer;
}

.sidebar-section-check input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}

.sidebar-section-check.completed {
    color: var(--success);
    text-decoration: line-through;
}

/* Mark Complete Button */
.btn-mark-complete {
    width: 100%;
    padding: var(--sp-3);
    background: var(--primary-gradient);
    color: var(--white);
    border: none;
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
}

.btn-mark-complete:hover {
    box-shadow: var(--shadow-purple);
    transform: translateY(-1px);
}

.btn-mark-complete.completed {
    background: var(--success);
    box-shadow: none;
}

/* ---- Tutorial Content ---- */
.tutorial-content {
    min-width: 0; /* prevent grid blowout */
}

.tutorial-content h2 {
    margin-top: var(--sp-12);
    padding-top: var(--sp-8);
    border-top: 1px solid var(--border);
}

.tutorial-content h2:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.tutorial-content h3 {
    margin-top: var(--sp-8);
}

/* Section numbering */
.tutorial-content h2 .section-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary-gradient);
    color: var(--white);
    border-radius: 50%;
    font-size: var(--text-sm);
    margin-right: var(--sp-3);
    flex-shrink: 0;
}

/* ---- Step Lists ---- */
.step-list {
    counter-reset: step;
    margin: var(--sp-6) 0;
}

.step-item {
    counter-increment: step;
    display: flex;
    gap: var(--sp-4);
    padding: var(--sp-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--sp-4);
}

.step-item::before {
    content: counter(step);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    background: var(--primary-gradient);
    color: var(--white);
    border-radius: 50%;
    font-weight: 600;
    font-size: var(--text-sm);
    flex-shrink: 0;
}

.step-content h4 {
    margin-bottom: var(--sp-2);
}

.step-content p:last-child {
    margin-bottom: 0;
}

/* ---- Complexity Table ---- */
.complexity-table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--sp-6) 0;
}

.complexity-table th {
    background: var(--primary-50);
    color: var(--primary-700);
    padding: var(--sp-3) var(--sp-4);
    text-align: left;
    font-weight: 600;
    font-size: var(--text-sm);
    border-bottom: 2px solid var(--primary-200);
}

.complexity-table td {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-light);
    font-size: var(--text-sm);
}

.complexity-table .complexity-good {
    color: var(--easy);
    font-weight: 600;
    font-family: var(--font-mono);
}

.complexity-table .complexity-ok {
    color: var(--medium);
    font-weight: 600;
    font-family: var(--font-mono);
}

.complexity-table .complexity-bad {
    color: var(--hard);
    font-weight: 600;
    font-family: var(--font-mono);
}

/* ---- Pattern Cards ---- */
.pattern-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--sp-4);
    margin: var(--sp-6) 0;
}

.pattern-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--sp-5);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.pattern-card:hover {
    border-color: var(--primary-300);
    box-shadow: var(--shadow-md);
}

.pattern-card h4 {
    color: var(--primary);
    margin-bottom: var(--sp-2);
    font-size: var(--text-base);
}

.pattern-card p {
    font-size: var(--text-sm);
    color: var(--gray-600);
    margin-bottom: 0;
}

/* ---- Practice Problems ---- */
.practice-problems {
    margin: var(--sp-6) 0;
}

.practice-problem {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--sp-4);
    overflow: hidden;
}

.practice-problem-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4);
    background: var(--gray-50);
    cursor: pointer;
}

.practice-problem-header h4 {
    margin-bottom: 0;
    font-size: var(--text-base);
}

.practice-problem-body {
    padding: var(--sp-4);
    display: none;
}

.practice-problem.open .practice-problem-body {
    display: block;
}

.hint-toggle,
.solution-toggle {
    background: none;
    border: 1px solid var(--border);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--gray-600);
    cursor: pointer;
    margin-top: var(--sp-2);
    margin-right: var(--sp-2);
    transition: all var(--transition);
}

.hint-toggle:hover {
    border-color: var(--info);
    color: var(--info);
}

.solution-toggle:hover {
    border-color: var(--success);
    color: var(--success);
}

.hint-content,
.solution-content {
    display: none;
    margin-top: var(--sp-3);
    padding: var(--sp-4);
    border-radius: var(--radius-md);
}

.hint-content.visible {
    display: block;
    background: #EFF6FF;
    border-left: 3px solid var(--info);
}

.solution-content.visible {
    display: block;
    background: #ECFDF5;
    border-left: 3px solid var(--success);
}

/* ---- Prev/Next Nav ---- */
.tutorial-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-4);
    margin-top: var(--sp-12);
    padding-top: var(--sp-8);
    border-top: 1px solid var(--border);
}

.tutorial-nav-link {
    display: flex;
    flex-direction: column;
    padding: var(--sp-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    transition: all var(--transition);
}

.tutorial-nav-link:hover {
    border-color: var(--primary-300);
    box-shadow: var(--shadow-md);
    color: var(--primary);
}

.tutorial-nav-link .label {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-400);
    margin-bottom: var(--sp-1);
}

.tutorial-nav-link .title {
    font-weight: 600;
    color: var(--gray-900);
}

.tutorial-nav-link:hover .title {
    color: var(--primary);
}

.tutorial-nav-link.next {
    text-align: right;
}

/* ---- Related Topics ---- */
.related-topics {
    margin-top: var(--sp-8);
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--sp-3);
}

.related-chip {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    background: var(--gray-50);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    color: var(--gray-700);
    text-decoration: none;
    transition: all var(--transition);
}

.related-chip:hover {
    background: var(--primary-50);
    border-color: var(--primary-300);
    color: var(--primary);
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .tutorial-layout {
        grid-template-columns: 220px 1fr;
        gap: var(--sp-6);
    }
}

@media (max-width: 768px) {
    .tutorial-layout {
        grid-template-columns: 1fr;
        padding: var(--sp-4);
    }

    .tutorial-sidebar {
        position: static;
        max-height: none;
        padding-right: 0;
        display: none;
    }

    .tutorial-sidebar.mobile-open {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        background: var(--surface);
        z-index: var(--z-modal);
        padding: var(--sp-6);
        box-shadow: var(--shadow-xl);
        overflow-y: auto;
    }

    .sidebar-mobile-toggle {
        display: flex;
        position: fixed;
        bottom: var(--sp-6);
        right: var(--sp-6);
        width: 48px;
        height: 48px;
        background: var(--primary-gradient);
        color: var(--white);
        border: none;
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        box-shadow: var(--shadow-purple-lg);
        z-index: var(--z-sticky);
        font-size: var(--text-lg);
    }

    .tutorial-hero {
        padding: var(--sp-8) 0 var(--sp-6);
    }

    .tutorial-hero h1 {
        font-size: var(--text-2xl);
    }

    .tutorial-nav {
        grid-template-columns: 1fr;
    }

    .tutorial-content h2 {
        margin-top: var(--sp-8);
        padding-top: var(--sp-6);
    }
}

/* Mobile sidebar toggle (hidden on desktop) */
.sidebar-mobile-toggle {
    display: none;
}

/* Sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-modal) - 1);
}

.sidebar-overlay.visible {
    display: block;
}
