/* ============================================
   fehlerhilfe.de — Main Stylesheet
   Mobile-first, CSS Variables, System Fonts
   ============================================ */

:root {
    --color-primary: #1a56db;
    --color-primary-dark: #1444b0;
    --color-accent: #059669;
    --color-warning: #d97706;
    --color-danger: #dc2626;
    --color-text: #1f2937;
    --color-text-light: #6b7280;
    --color-bg: #ffffff;
    --color-bg-alt: #f8fafc;
    --color-border: #e5e7eb;
    --color-card-bg: #ffffff;
    --font-family: -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', monospace;
    --max-width: 1100px;
    --line-height: 1.7;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --transition: 0.2s ease;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font-family);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: var(--line-height);
    -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--color-primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--color-primary-dark); }
ul, ol { list-style: none; }

/* Container */
.container { width: 100%; max-width: var(--max-width); margin: 0 auto; padding: 0 1rem; }

/* ---- HEADER ---- */
.site-header {
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    padding: 0.75rem 0;
}
.logo {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 1.25rem;
    color: var(--color-text);
    white-space: nowrap;
}
.logo:hover { color: var(--color-primary); }
.logo-icon { font-size: 1.4rem; }
.logo-text { font-weight: 400; }
.logo-text strong { font-weight: 700; color: var(--color-primary); }

.main-nav { display: none; }
.main-nav.is-open { display: block; position: absolute; top: 60px; left: 0; right: 0; background: var(--color-bg); border-bottom: 1px solid var(--color-border); padding: 1rem; z-index: 99; }
.main-nav ul { display: flex; flex-direction: column; gap: 0.5rem; }
.main-nav a { display: block; padding: 0.5rem 0; color: var(--color-text); font-size: 0.95rem; }
.main-nav a:hover { color: var(--color-primary); }

.nav-toggle {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    margin-left: auto;
}
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--color-text); transition: var(--transition); }

.header-search {
    display: none;
}

/* ---- HERO ---- */
.hero {
    text-align: center;
    padding: 3rem 0 2rem;
    background: var(--color-bg-alt);
    margin: 0 -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
}
.hero h1 { font-size: 1.75rem; margin-bottom: 0.5rem; }
.hero p { color: var(--color-text-light); margin-bottom: 1.5rem; }
.hero-search {
    display: flex;
    max-width: 560px;
    margin: 0 auto;
    gap: 0.5rem;
}
.hero-search input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: var(--font-family);
    transition: border-color var(--transition);
}
.hero-search input:focus { outline: none; border-color: var(--color-primary); }

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: var(--font-family);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); color: #fff; }
.btn-secondary { background: var(--color-bg-alt); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-border); }
.btn-accent { background: var(--color-accent); color: #fff; }
.btn-danger { background: var(--color-danger); color: #fff; }

/* ---- SECTIONS ---- */
.section { padding: 2rem 0; }
.section-title { font-size: 1.5rem; margin-bottom: 1.25rem; }

/* ---- CATEGORY GRID ---- */
.category-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
.category-card {
    display: block;
    padding: 1.5rem;
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: box-shadow var(--transition), border-color var(--transition);
    color: var(--color-text);
}
.category-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md); color: var(--color-text); }
.category-card__icon { font-size: 2rem; display: block; margin-bottom: 0.5rem; }
.category-card h3 { font-size: 1.1rem; margin-bottom: 0.3rem; }
.category-card p { font-size: 0.9rem; color: var(--color-text-light); }

/* ---- POST GRID ---- */
.post-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}
.post-grid--4 { grid-template-columns: 1fr; }

.post-card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow var(--transition);
}
.post-card:hover { box-shadow: var(--shadow-md); }
.post-card__image img { width: 100%; height: 180px; object-fit: cover; }
.post-card__body { padding: 1rem; }
.post-card__category {
    display: inline-block;
    font-size: 0.8rem;
    color: var(--color-primary);
    font-weight: 600;
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.post-card__body h2,
.post-card__body h3,
.post-card__body h4 { font-size: 1.05rem; margin-bottom: 0.4rem; line-height: 1.4; }
.post-card__body h2 a,
.post-card__body h3 a,
.post-card__body h4 a { color: var(--color-text); }
.post-card__body h2 a:hover,
.post-card__body h3 a:hover,
.post-card__body h4 a:hover { color: var(--color-primary); }
.post-card__body p { font-size: 0.9rem; color: var(--color-text-light); }
.post-card__meta { font-size: 0.8rem; color: var(--color-text-light); margin-top: 0.5rem; display: block; }

/* Horizontal card */
.post-card--horizontal { display: flex; flex-direction: column; }
.post-card--horizontal .post-card__image { flex-shrink: 0; }
.post-card--horizontal .post-card__image img { height: 160px; }

/* Post list */
.post-list { display: flex; flex-direction: column; gap: 1.25rem; }

/* ---- CONTENT WITH SIDEBAR ---- */
.content-with-sidebar { display: flex; flex-direction: column; gap: 2rem; padding: 2rem 0; }
.content-main { flex: 1; min-width: 0; }

/* ---- SIDEBAR ---- */
.sidebar { width: 100%; }
.sidebar__widget { margin-bottom: 1.5rem; padding: 1.25rem; background: var(--color-bg-alt); border-radius: var(--radius); }
.sidebar__widget h3 { font-size: 1rem; margin-bottom: 0.75rem; }
.sidebar__categories li,
.sidebar__popular li { margin-bottom: 0.5rem; }
.sidebar__categories a,
.sidebar__popular a { color: var(--color-text); font-size: 0.9rem; display: flex; justify-content: space-between; }
.sidebar__categories a:hover,
.sidebar__popular a:hover { color: var(--color-primary); }
.badge {
    background: var(--color-primary);
    color: #fff;
    font-size: 0.75rem;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-weight: 600;
}

/* ---- BREADCRUMB ---- */
.breadcrumb { padding: 1rem 0 0; font-size: 0.85rem; }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.breadcrumb li::after { content: '›'; margin-left: 0.3rem; color: var(--color-text-light); }
.breadcrumb li:last-child::after { content: ''; }
.breadcrumb li:last-child { color: var(--color-text-light); }
.breadcrumb a { color: var(--color-text); }
.breadcrumb a:hover { color: var(--color-primary); }

/* ---- ARTICLE ---- */
.article__header { margin-bottom: 1.5rem; }
.article__header h1 { font-size: 1.75rem; line-height: 1.3; margin-bottom: 0.5rem; }
.article__meta { display: flex; flex-wrap: wrap; gap: 1rem; font-size: 0.85rem; color: var(--color-text-light); }
.article__category { color: var(--color-primary); font-weight: 600; }
.article__updated { font-style: italic; }
.article__featured-image { margin-bottom: 1.5rem; border-radius: var(--radius); overflow: hidden; }

/* Article content */
.article__content { font-size: 1rem; line-height: var(--line-height); }
.article__content h2 { font-size: 1.35rem; margin: 2rem 0 0.75rem; padding-bottom: 0.3rem; border-bottom: 2px solid var(--color-bg-alt); }
.article__content h3 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; }
.article__content p { margin-bottom: 1rem; }
.article__content ul, .article__content ol { margin: 0.5rem 0 1rem 1.5rem; }
.article__content ul { list-style: disc; }
.article__content ol { list-style: decimal; }
.article__content li { margin-bottom: 0.4rem; }
.article__content strong { font-weight: 600; }
.article__content a { color: var(--color-primary); text-decoration: underline; }
.article__content img { border-radius: var(--radius); margin: 1rem 0; }
.article__content mark { background: #fef3c7; padding: 0.1rem 0.2rem; border-radius: 2px; }

/* TOC */
.toc {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.toc h3 { font-size: 1rem; margin-bottom: 0.75rem; }
.toc ol { list-style: decimal; margin-left: 1.25rem; }
.toc li { margin-bottom: 0.3rem; }
.toc a { color: var(--color-text); font-size: 0.9rem; }
.toc a:hover { color: var(--color-primary); }

/* FAQ */
.faq-section { margin-top: 2rem; }
.faq-section h2 { font-size: 1.35rem; margin-bottom: 1rem; }
.faq-item {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}
.faq-item summary {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before { content: '▸ '; color: var(--color-primary); }
.faq-item[open] summary::before { content: '▾ '; }
.faq-item__answer { padding: 0 1rem 0.75rem; font-size: 0.95rem; color: var(--color-text-light); }

/* Share buttons */
.share-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin: 2rem 0;
    padding: 1rem 0;
    border-top: 1px solid var(--color-border);
    font-size: 0.9rem;
}
.share-buttons span { font-weight: 600; }
.share-buttons a {
    padding: 0.4rem 0.8rem;
    background: var(--color-bg-alt);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 0.85rem;
}
.share-buttons a:hover { background: var(--color-primary); color: #fff; }

/* Related posts */
.related-posts { margin-top: 2rem; padding-top: 2rem; border-top: 1px solid var(--color-border); }
.related-posts h3 { font-size: 1.25rem; margin-bottom: 1rem; }

/* ---- PAGINATION ---- */
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    margin-top: 2rem;
}
.pagination a, .pagination__page {
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 0.9rem;
}
.pagination a:hover, .pagination__page:hover { border-color: var(--color-primary); color: var(--color-primary); }
.pagination .is-active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ---- SEARCH ---- */
.search-form {
    display: flex;
    gap: 0.5rem;
    margin: 1.5rem 0;
}
.search-form input {
    flex: 1;
    padding: 0.65rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: var(--font-family);
}
.search-form input:focus { outline: none; border-color: var(--color-primary); }
.search-count { color: var(--color-text-light); margin-bottom: 1rem; }
.no-results { color: var(--color-text-light); font-style: italic; }

/* ---- ERROR PAGE ---- */
.error-page { text-align: center; padding: 4rem 0; }
.error-page h1 { font-size: 2rem; margin-bottom: 1rem; }
.error-page p { margin-bottom: 1rem; color: var(--color-text-light); }

/* ---- STATIC PAGE ---- */
.static-page { padding: 2rem 0; max-width: 800px; }
.static-page h1 { font-size: 1.75rem; margin-bottom: 1rem; }
.static-page h2 { font-size: 1.3rem; margin: 1.5rem 0 0.5rem; }
.static-page p { margin-bottom: 1rem; }

/* ---- PAGE HEADER ---- */
.page-header { padding: 1.5rem 0; }
.page-header h1 { font-size: 1.75rem; margin-bottom: 0.5rem; }
.page-header__desc { color: var(--color-text-light); }

/* ---- FOOTER ---- */
.site-footer {
    background: var(--color-text);
    color: #d1d5db;
    padding: 2.5rem 0 1rem;
    margin-top: 3rem;
}
.footer-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; margin-bottom: 2rem; }
.footer-about .logo-text { color: #fff; font-size: 1.1rem; display: block; margin-bottom: 0.5rem; }
.footer-about .logo-text strong { color: var(--color-primary); }
.footer-about p { font-size: 0.9rem; }
.footer-links h4 { color: #fff; font-size: 0.95rem; margin-bottom: 0.75rem; }
.footer-links li { margin-bottom: 0.4rem; }
.footer-links a { color: #d1d5db; font-size: 0.9rem; }
.footer-links a:hover { color: #fff; }
.footer-bottom { border-top: 1px solid #374151; padding-top: 1rem; text-align: center; font-size: 0.85rem; }

/* ---- AD SLOTS ---- */
.ad-slot { margin: 1.5rem 0; text-align: center; min-height: 90px; }
.ad-between-list { margin: 1rem 0; }
.ad-after-h1 { margin: 1rem 0 1.5rem; }

/* ---- COOKIE CONSENT ---- */
.cookie-consent {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-text);
    color: #fff;
    z-index: 9999;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
}
.cookie-consent-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.cookie-consent-inner p { font-size: 0.9rem; }
.cookie-consent-inner a { color: #93c5fd; }
.cookie-consent-buttons { display: flex; gap: 0.5rem; }

/* ---- DESKTOP (≥768px) ---- */
@media (min-width: 768px) {
    .nav-toggle { display: none; }
    .main-nav {
        display: flex !important;
        position: static;
        border: none;
        padding: 0;
        background: none;
        order: 3;
        width: 100%;
        border-top: 1px solid var(--color-border);
        padding-top: 0.5rem;
    }
    .main-nav ul { flex-direction: row; gap: 0.25rem; }
    .main-nav a {
        padding: 0.35rem 0.7rem;
        border-radius: var(--radius);
        font-size: 0.85rem;
        white-space: nowrap;
    }
    .main-nav a:hover { background: var(--color-bg-alt); }
    .header-search { display: flex; margin-left: auto; }
    .header-search input {
        width: 200px;
        padding: 0.4rem 0.75rem;
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        font-size: 0.9rem;
        font-family: var(--font-family);
    }
    .header-search button {
        background: none;
        border: none;
        cursor: pointer;
        margin-left: -2rem;
    }

    .hero h1 { font-size: 2.25rem; }
    .category-grid { grid-template-columns: repeat(3, 1fr); }
    .post-grid { grid-template-columns: repeat(2, 1fr); }
    .post-grid--4 { grid-template-columns: repeat(2, 1fr); }

    .post-card--horizontal { flex-direction: row; }
    .post-card--horizontal .post-card__image { width: 240px; }
    .post-card--horizontal .post-card__image img { height: 100%; min-height: 160px; }

    .content-with-sidebar { flex-direction: row; }
    .sidebar { width: 280px; flex-shrink: 0; }

    .footer-grid { grid-template-columns: 2fr 1fr 1fr; }

    .cookie-consent-inner { flex-direction: row; align-items: center; }
}

@media (min-width: 992px) {
    .post-grid { grid-template-columns: repeat(3, 1fr); }
    .post-grid--4 { grid-template-columns: repeat(4, 1fr); }
    .category-grid { grid-template-columns: repeat(5, 1fr); }

    .ad-sidebar-sticky { position: sticky; top: 80px; }
}

/* ---- ADMIN STYLES ---- */
.admin-wrap { max-width: 1000px; margin: 0 auto; padding: 1rem; }
.admin-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 0; border-bottom: 1px solid var(--color-border); margin-bottom: 1.5rem; }
.admin-header h1 { font-size: 1.25rem; }
.admin-nav { display: flex; gap: 1rem; }
.admin-nav a { color: var(--color-text); font-size: 0.9rem; }
.admin-nav a:hover { color: var(--color-primary); }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.3rem; }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: var(--font-family);
}
.form-group textarea { min-height: 200px; resize: vertical; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--color-primary); }
.form-group .help-text { font-size: 0.8rem; color: var(--color-text-light); margin-top: 0.2rem; }

.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }

.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.9rem; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--color-border); }
.data-table th { font-weight: 600; background: var(--color-bg-alt); }
.data-table tr:hover { background: var(--color-bg-alt); }

.status-badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 10px; font-size: 0.8rem; font-weight: 600; }
.status-published { background: #d1fae5; color: #065f46; }
.status-draft { background: #fef3c7; color: #92400e; }

.dashboard-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--color-bg-alt); padding: 1.25rem; border-radius: var(--radius); text-align: center; }
.stat-card__number { font-size: 2rem; font-weight: 700; color: var(--color-primary); }
.stat-card__label { font-size: 0.85rem; color: var(--color-text-light); }

.seo-warnings { margin: 1rem 0; }
.seo-warnings li { padding: 0.3rem 0; font-size: 0.85rem; color: var(--color-warning); }
.seo-warnings li::before { content: '⚠ '; }
