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

:root {
    --primary: #1a365d;
    --primary-light: #2c5282;
    --accent: #2b6cb0;
    --success: #38a169;
    --warning: #dd6b20;
    --danger: #e53e3e;
    --bg: #fff;
    --bg-alt: #f7f9fc;
    --text: #333;
    --text-muted: #718096;
    --sidebar-width: 280px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    line-height: 1.6;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}

/* Lucide Icons */
[data-lucide] {
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    stroke-width: 2;
}

button [data-lucide],
.test-meta [data-lucide] {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 0.25em;
}

.nav-btn [data-lucide] {
    margin: 0;
}

.menu-toggle [data-lucide] {
    width: 24px;
    height: 24px;
    margin: 0;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.3s;
    z-index: 1000;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
    font-size: 1.2rem;
    font-weight: 600;
}

.sidebar-header p {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 0.3rem;
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-section {
    margin-bottom: 1rem;
}

.nav-section-title {
    padding: 0.5rem 1.5rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.5;
}

.nav-item {
    display: block;
    padding: 0.7rem 1.5rem;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.nav-item.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-left: 3px solid var(--accent);
}

.nav-item-icon {
    margin-right: 0.5rem;
    display: inline-flex;
    align-items: center;
}

.nav-item-icon [data-lucide],
.nav-section-title [data-lucide] {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

/* Main content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* Header */
.page-header {
    background: var(--bg-alt);
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e2e8f0;
}

.page-header h2 {
    color: var(--primary);
    font-size: 1.4rem;
    font-weight: 600;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.3rem;
}

/* Search & Filters */
.filters-bar {
    background: var(--bg);
    padding: 1rem 2rem;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.search-input {
    width: 100%;
    max-width: 400px;
    padding: 0.7rem 1rem;
    border: 1px solid #e2e8f0;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
}

.search-input:focus {
    border-color: var(--accent);
}

.filter-group {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    background: var(--bg);
    color: var(--accent);
    border: 1px solid #e2e8f0;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: var(--bg-alt);
}

.filter-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Content area */
.content-area {
    padding: 2rem;
}

/* Files grid */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.file-card {
    background: var(--bg);
    border: 1px solid #e2e8f0;
    padding: 1rem;
    transition: all 0.2s;
}

.file-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.file-card.hidden {
    display: none;
}

.file-card a {
    color: var(--text);
    text-decoration: none;
    display: flex;
    gap: 1rem;
}

.file-card a:hover .file-name {
    color: var(--accent);
}

.file-icon {
    width: 48px;
    height: 48px;
    background: var(--danger);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.7rem;
    color: white;
    flex-shrink: 0;
}

.file-icon.odpowiedzi {
    background: var(--success);
}

.file-card.external::after {
    content: "🔗";
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.7rem;
    opacity: 0.6;
}

.file-card.external {
    position: relative;
}

.file-icon.zip { background: var(--warning); }
.file-icon.odpowiedzi { background: var(--success); }

.file-info { flex: 1; }
.file-name { font-weight: 500; font-size: 0.95rem; }
.file-meta { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.2rem; }
.file-tags { color: #a0aec0; font-size: 0.75rem; margin-top: 0.3rem; }

/* Stats */
.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.stats-text {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Section title */
.section-title {
    color: var(--primary-light);
    font-size: 1rem;
    font-weight: 500;
    margin: 2rem 0 1rem;
    padding: 0.5rem 1rem;
    background: var(--bg-alt);
}

/* No results */
.no-results {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
    display: none;
}

.no-results.visible {
    display: block;
}

/* Mobile menu toggle */
.menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0.7rem;
    cursor: pointer;
    font-size: 1.2rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    background: var(--bg-alt);
    border-top: 1px solid #e2e8f0;
}

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

/* Tests Grid */
.tests-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.test-card {
    background: var(--bg);
    border: 1px solid #e2e8f0;
    padding: 1.2rem;
    transition: all 0.2s;
}

.test-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.test-card.completed {
    border-left: 3px solid var(--success);
}

.test-card.in-progress {
    border-left: 3px solid var(--warning);
}

.test-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.test-category {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.05em;
}

.test-difficulty {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    background: #e2e8f0;
}

.test-difficulty.easy { background: #c6f6d5; color: #22543d; }
.test-difficulty.medium { background: #feebc8; color: #744210; }
.test-difficulty.hard { background: #fed7d7; color: #742a2a; }

.test-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.test-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.test-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    gap: 1rem;
    margin-bottom: 0.8rem;
}

.test-progress {
    margin-bottom: 0.8rem;
}

.progress-bar {
    height: 4px;
    background: #e2e8f0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
}

.progress-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.test-btn {
    width: 100%;
    padding: 0.6rem;
    background: var(--accent);
    color: #fff;
    border: none;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
}

.test-btn:hover {
    background: var(--primary);
}

.test-btn.secondary {
    background: #e2e8f0;
    color: var(--text);
}

.test-btn.secondary:hover {
    background: #cbd5e0;
}

.test-buttons {
    display: flex;
    gap: 0.5rem;
}

.test-buttons .test-btn {
    flex: 1;
}

.test-buttons .reset-btn {
    flex: 0 0 auto;
    width: auto;
    padding: 0.6rem 1rem;
    background: #64748b;
}

.test-buttons .reset-btn:hover {
    background: #475569;
}

/* Test Question */
.test-container {
    max-width: 700px;
    margin: 0 auto;
}

.test-progress-bar {
    height: 4px;
    background: #e2e8f0;
    margin-bottom: 2rem;
}

.question-card {
    background: var(--bg);
    border: 1px solid #e2e8f0;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.question-text {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
}

.answers-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.answer-btn {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    background: var(--bg);
    border: 1px solid #e2e8f0;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.answer-btn:hover:not(:disabled) {
    background: var(--bg-alt);
    border-color: var(--accent);
}

.answer-btn.selected {
    background: #ebf8ff;
    border-color: var(--accent);
}

/* Green - selected AND correct (dobrze!) */
.test-container .answers-list .answer-btn.selected-correct {
    background: #f0fff4;
    border: 3px solid #38a169;
}

.test-container .answers-list .answer-btn.selected-correct .answer-letter {
    background: #38a169;
    color: white;
}

.test-container .answers-list button.answer-btn.selected-correct:disabled {
    background: #f0fff4;
    opacity: 1;
    cursor: default;
}

/* Red border - selected but wrong (źle!) */
.test-container .answers-list .answer-btn.selected-wrong {
    background: #fff5f5;
    border: 3px solid #e53e3e;
}

.test-container .answers-list .answer-btn.selected-wrong .answer-letter {
    background: #e53e3e;
    color: white;
}

.test-container .answers-list button.answer-btn.selected-wrong:disabled {
    background: #fff5f5;
    opacity: 1;
    cursor: default;
}

.answer-btn.selected-wrong .answer-letter {
    background: var(--danger);
    color: white;
}

/* Blue border - correct answer (shown when user selected wrong) */
.test-container .answers-list .answer-btn.correct {
    background: #ebf8ff;
    border: 3px solid #3182ce;
}

.test-container .answers-list .answer-btn.correct .answer-letter {
    background: #3182ce;
    color: white;
}

.test-container .answers-list button.answer-btn.correct:disabled {
    background: #ebf8ff;
    opacity: 1;
    cursor: default;
}

.answer-letter {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e2e8f0;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.answer-text {
    flex: 1;
}

.answer-text code {
    background: var(--bg-dark);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: #e06c75;
}

.answer-btn.selected .answer-text code,
.answer-btn:hover .answer-text code {
    background: rgba(255,255,255,0.1);
}

/* Highlight.js overrides for inline code */
.answer-text code.hljs {
    padding: 0.15rem 0.4rem;
    background: var(--bg-dark);
}

.explanation {
    margin-top: 1rem;
    padding: 1rem;
    background: #ebf8ff;
    font-size: 0.9rem;
}

.test-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.nav-btn {
    padding: 0.6rem 1.2rem;
    background: var(--bg);
    border: 1px solid #e2e8f0;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.nav-btn:hover:not(:disabled) {
    background: var(--bg-alt);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nav-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.question-dots {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    justify-content: center;
}

.dot {
    width: 10px;
    height: 10px;
    background: #e2e8f0;
    cursor: pointer;
    transition: all 0.2s;
}

.dot.current {
    background: var(--accent);
}

.dot.answered {
    background: var(--success);
}

.test-result {
    text-align: center;
    padding: 2rem;
    background: var(--bg-alt);
    margin-top: 2rem;
}

.test-result h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.test-result .test-btn {
    max-width: 200px;
    margin: 0.5rem;
    display: inline-block;
}

.test-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.action-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-family: inherit;
    border: 1px solid #cbd5e0;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.action-btn:hover {
    background: #f1f5f9;
}

.action-btn.reset {
    border-color: #f59e0b;
    color: #b45309;
}

.action-btn.reset:hover {
    background: #fef3c7;
}

.action-btn.back {
    border-color: #64748b;
    color: #475569;
}

.action-btn.back:hover {
    background: #f1f5f9;
}

/* Knowledge Base */
.knowledge-grid {
    display: block;
}

.knowledge-section {
    width: 100%;
    margin-bottom: 2rem;
}

.knowledge-section .section-title {
    color: var(--primary);
    font-size: 1rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    background: var(--bg-alt);
    margin-bottom: 1rem;
}

.knowledge-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    grid-auto-rows: auto;
    grid-auto-flow: row dense;
    gap: 1rem;
    align-items: start;
}

.knowledge-card {
    background: var(--bg);
    border: 1px solid #e2e8f0;
    padding: 1rem;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    display: block;
}

.content-area .knowledge-section .knowledge-grid .knowledge-card.hidden,
.content-area .knowledge-section .knowledge-grid .knowledge-card[style*="display: none"] {
    display: none;
}

.knowledge-header {
    margin-bottom: 0.5rem;
}

.knowledge-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
    word-break: break-word;
    overflow-wrap: break-word;
}

.knowledge-syntax {
    background: var(--bg-alt);
    padding: 0.5rem;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    overflow-x: auto;
    max-width: 100%;
}

.knowledge-syntax code {
    white-space: pre;
    display: block;
}

.knowledge-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.knowledge-example {
    font-size: 0.85rem;
}

.knowledge-example summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 500;
}

.knowledge-example pre {
    background: #1a202c;
    color: #e2e8f0;
    padding: 0.8rem;
    margin-top: 0.5rem;
    overflow-x: auto;
    font-size: 0.8rem;
    line-height: 1.5;
    max-width: 100%;
}

.knowledge-example pre code {
    white-space: pre;
}

/* Color Picker */
.color-picker-container {
    max-width: 400px;
    margin: 2rem auto;
    text-align: center;
}

.color-picker-container input[type="color"] {
    width: 150px;
    height: 150px;
    cursor: pointer;
    border: none;
    padding: 0;
}

.color-inputs {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 1rem 0;
}

.color-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.color-input-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.color-input-group input {
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    text-align: center;
    font-family: monospace;
    font-size: 0.9rem;
}

.color-preview {
    padding: 2rem;
    font-weight: 500;
}

/* Placeholder & Error */
.placeholder, .error-message {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.placeholder p:first-child {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.error-message {
    color: var(--danger);
}

/* RWD */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .page-header {
        padding-left: 4rem;
    }
}

@media (max-width: 768px) {
    .files-grid {
        grid-template-columns: 1fr;
    }
    
    .filters-bar {
        padding: 1rem;
    }
    
    .content-area {
        padding: 1rem;
    }
    
    .page-header {
        padding: 1rem;
        padding-left: 4rem;
    }
    
    .filter-group {
        gap: 0.3rem;
    }
    
    .filter-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .file-card {
        padding: 0.8rem;
    }
    
    .file-icon {
        width: 40px;
        height: 40px;
    }
    
    .search-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}
