/**
 * wiki.css — wiki-specific styles for netadm.pro Wiki
 * Relies on global style.css for CSS variables and base styles.
 */

/* ── Wiki navigation bar ─────────────────────────────────────────────────── */

.wiki-nav {
    display: flex;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.wiki-nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    width: 100%;
}

.wiki-nav-link {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    border-right: 1px solid var(--border);
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-bottom-color 0.15s, background 0.15s;
    white-space: nowrap;
}

.wiki-nav-link:last-child {
    border-right: none;
}

.wiki-nav-link:hover {
    color: var(--text);
    background: var(--btn-secondary-hover);
}

.wiki-nav-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: var(--btn-secondary-hover);
}

.wiki-nav-new {
    margin-left: auto;
    color: var(--accent);
    border-left: 1px solid var(--border);
    border-right: none;
}

.wiki-nav-new:hover {
    color: var(--accent-hover);
}

/* ── Flash messages ───────────────────────────────────────────────────────── */

.wiki-flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    border-left: 3px solid var(--accent);
    background: var(--surface);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 0;
}

.wiki-flash--success {
    border-left-color: var(--success);
    color: var(--success);
    background: rgba(62, 207, 142, 0.08);
}

.wiki-flash--error {
    border-left-color: var(--error);
    color: var(--error);
    background: rgba(245, 101, 101, 0.08);
}

.wiki-flash--info {
    border-left-color: var(--accent);
    color: var(--accent);
    background: rgba(91, 127, 255, 0.08);
}

/* ── Home page layout ─────────────────────────────────────────────────────── */

.wiki-home-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
    align-items: start;
}

.wiki-sections-list {
    display: flex;
    flex-direction: column;
}

.wiki-section-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s, color 0.15s;
}

.wiki-section-row:last-child {
    border-bottom: none;
}

.wiki-section-row:hover {
    background: var(--btn-secondary-hover);
    color: var(--accent);
}

.wiki-section-name {
    font-size: 14px;
    font-weight: 500;
}

.wiki-section-count {
    font-size: 12px;
    color: var(--muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1px 8px;
    min-width: 28px;
    text-align: center;
    flex-shrink: 0;
}

/* ── Article list ─────────────────────────────────────────────────────────── */

.wiki-article-list {
    display: flex;
    flex-direction: column;
}

.wiki-article-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    transition: color 0.15s;
}

.wiki-article-row:last-child {
    border-bottom: none;
}

.wiki-article-row:hover {
    color: var(--accent);
}

.wiki-article-title {
    font-size: 14px;
    font-weight: 500;
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.wiki-article-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--muted);
    flex-shrink: 0;
    white-space: nowrap;
}

.wiki-section-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 3px;
    background: rgba(91, 127, 255, 0.12);
    border: 1px solid rgba(91, 127, 255, 0.25);
    color: var(--accent);
    flex-shrink: 0;
}

.wiki-empty {
    color: var(--muted);
    font-size: 14px;
    text-align: center;
    padding: 32px 0;
}

/* ── Auth forms ───────────────────────────────────────────────────────────── */

.wiki-auth-wrap {
    display: flex;
    justify-content: center;
}

.wiki-auth-card {
    width: 100%;
    max-width: 420px;
}

.wiki-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.wiki-input {
    width: 100%;
    font-family: var(--font) !important;
    font-size: 14px !important;
}

.wiki-select {
    width: 100%;
    font-family: var(--font) !important;
    font-size: 14px !important;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='none' stroke='%239aa0c0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='4,6 8,10 12,6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px !important;
}

.wiki-textarea {
    width: 100%;
    resize: vertical;
    min-height: 80px;
    font-family: var(--font) !important;
    font-size: 14px !important;
    line-height: 1.6;
}

.wiki-submit-btn {
    padding: 11px 20px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    width: 100%;
}

.wiki-submit-btn:hover {
    border-color: var(--accent);
    color: #fff;
}

.wiki-auth-link {
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}

.wiki-auth-link a {
    color: var(--link);
}

/* ── Article view ─────────────────────────────────────────────────────────── */

.wiki-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
    flex-wrap: wrap;
}

.wiki-breadcrumb a {
    color: var(--muted);
}

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

.wiki-bc-sep {
    color: var(--border);
}

.wiki-article-layout {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 24px;
    align-items: start;
}

.wiki-article-header {
    gap: 12px;
    flex-wrap: wrap;
}

.wiki-article-h2 {
    font-size: 15px !important;
    font-weight: 700 !important;
    letter-spacing: 0.3px !important;
    text-transform: none !important;
    color: var(--text) !important;
}

/* Article body — rendered Markdown ──────────────────────────────────────── */

.wiki-article-body {
    font-size: 15px;
    line-height: 1.75;
    color: var(--text);
    word-break: break-word;
    overflow-wrap: break-word;
}

.wiki-article-body h1,
.wiki-article-body h2,
.wiki-article-body h3,
.wiki-article-body h4,
.wiki-article-body h5,
.wiki-article-body h6 {
    margin: 1.5em 0 0.5em;
    line-height: 1.3;
    color: var(--text);
    font-weight: 700;
}

.wiki-article-body h1 { font-size: 1.7em; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.wiki-article-body h2 { font-size: 1.35em; border-bottom: 1px solid var(--border); padding-bottom: 6px; color: var(--accent); }
.wiki-article-body h3 { font-size: 1.15em; }
.wiki-article-body h4 { font-size: 1em; }

.wiki-article-body h1:first-child,
.wiki-article-body h2:first-child,
.wiki-article-body h3:first-child {
    margin-top: 0;
}

.wiki-article-body p {
    margin: 0 0 1em;
}

.wiki-article-body p:last-child {
    margin-bottom: 0;
}

.wiki-article-body a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-color: rgba(91, 159, 255, 0.4);
}

.wiki-article-body a:hover {
    color: var(--link-hover);
    text-decoration-color: var(--link-hover);
}

.wiki-article-body ul,
.wiki-article-body ol {
    padding-left: 24px;
    margin: 0 0 1em;
}

.wiki-article-body li {
    margin-bottom: 4px;
}

.wiki-article-body li + li {
    margin-top: 2px;
}

.wiki-article-body blockquote {
    border-left: 3px solid var(--accent);
    padding: 8px 16px;
    margin: 1em 0;
    background: rgba(91, 127, 255, 0.06);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--muted);
}

.wiki-article-body code {
    font-family: var(--mono);
    font-size: 0.88em;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 5px;
    color: var(--text);
}

.wiki-article-body pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    overflow-x: auto;
    margin: 1em 0;
    font-size: 0.88em;
    line-height: 1.65;
}

.wiki-article-body pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
}

.wiki-article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    font-size: 14px;
    overflow-x: auto;
    display: block;
}

.wiki-article-body th {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 8px 12px;
    font-weight: 700;
    text-align: left;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wiki-article-body td {
    border: 1px solid var(--border);
    padding: 8px 12px;
}

.wiki-article-body tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.02);
}

[data-theme="light"] .wiki-article-body tr:nth-child(even) td {
    background: rgba(0, 0, 0, 0.02);
}

.wiki-article-body img {
    max-width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.wiki-article-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5em 0;
}

/* Search highlight */
.wiki-highlight {
    background: rgba(255, 210, 0, 0.25);
    border-radius: 2px;
    padding: 0 2px;
    color: inherit;
}

[data-theme="light"] .wiki-highlight {
    background: rgba(255, 180, 0, 0.3);
}

/* Table of contents */

.wiki-toc {
    font-size: 13px;
}

.wiki-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wiki-toc-list a {
    color: var(--muted);
    text-decoration: none;
    font-size: 12px;
    line-height: 1.4;
    display: block;
    padding: 2px 4px;
    border-radius: 3px;
    transition: color 0.15s, background 0.15s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wiki-toc-list a:hover {
    color: var(--accent);
    background: rgba(91, 127, 255, 0.08);
}

/* ── Comments ─────────────────────────────────────────────────────────────── */

.wiki-comment-count {
    font-size: 11px;
    color: var(--muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1px 7px;
    margin-left: 6px;
    font-weight: 400;
}

.wiki-comments {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.wiki-comment {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.wiki-comment:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.wiki-comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.wiki-comment-author {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}

.wiki-comment-date {
    font-size: 12px;
    color: var(--muted);
    margin-left: auto;
}

.wiki-comment-body {
    font-size: 14px;
    line-height: 1.65;
    color: var(--text);
    word-break: break-word;
    white-space: pre-wrap;
}

.wiki-comment-form {
    margin-top: 8px;
}

/* ── Role badges ──────────────────────────────────────────────────────────── */

.wiki-role-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 3px;
    flex-shrink: 0;
}

.wiki-role-admin {
    background: rgba(245, 101, 101, 0.12);
    border: 1px solid rgba(245, 101, 101, 0.3);
    color: var(--error);
}

.wiki-role-editor {
    background: rgba(91, 127, 255, 0.12);
    border: 1px solid rgba(91, 127, 255, 0.3);
    color: var(--accent);
}

.wiki-role-reader {
    background: rgba(154, 160, 192, 0.1);
    border: 1px solid var(--border);
    color: var(--muted);
}

/* ── Editor ───────────────────────────────────────────────────────────────── */

.wiki-editor-form {
    gap: 20px;
}

.wiki-editor-tabs {
    display: flex;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    overflow: hidden;
    border-bottom: none;
}

.wiki-editor-tab {
    flex: 1;
    padding: 10px 0;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    background: var(--bg);
    border: none;
    border-right: 1px solid var(--border);
    border-bottom: 2px solid transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-bottom-color 0.15s;
    border-radius: 0;
}

.wiki-editor-tab:last-child {
    border-right: none;
}

.wiki-editor-tab.active {
    background: var(--surface);
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.wiki-editor-tab:hover:not(.active) {
    color: var(--text);
}

.wiki-editor-panel {
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--surface);
    padding: 16px;
}

.wiki-editor-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    min-height: 400px;
}

.wiki-editor-pane {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.wiki-editor-pane .wiki-md-editor {
    flex: 1;
    min-height: 400px;
    resize: vertical;
    font-family: var(--mono) !important;
    font-size: 13px !important;
    line-height: 1.65;
}

.wiki-preview-pane {
    flex: 1;
    min-height: 400px;
    overflow-y: auto;
    padding: 8px 0;
    border-left: 1px solid var(--border);
    padding-left: 16px;
}

.wiki-form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    padding-top: 4px;
}

/* ── Profile ──────────────────────────────────────────────────────────────── */

.wiki-profile-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    align-items: start;
}

.wiki-profile-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.wiki-profile-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wiki-profile-field {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wiki-profile-value {
    font-size: 14px;
    color: var(--text);
}

/* ── Search ───────────────────────────────────────────────────────────────── */

.wiki-search-form {
    margin-bottom: 16px;
    gap: 0;
}

.wiki-search-row {
    display: flex;
    gap: 8px;
}

.wiki-search-count {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 12px;
}

.wiki-search-headline {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.55;
    margin-top: 4px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.wiki-search-headline mark {
    background: rgba(255, 210, 0, 0.25);
    color: inherit;
    border-radius: 2px;
    padding: 0 2px;
}

[data-theme="light"] .wiki-search-headline mark {
    background: rgba(255, 180, 0, 0.3);
}

/* ── Pagination ───────────────────────────────────────────────────────────── */

.wiki-pagination {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.wiki-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s;
}

.wiki-page-btn:hover {
    border-color: var(--accent);
    color: var(--text);
}

.wiki-page-btn.active {
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Admin panel ──────────────────────────────────────────────────────────── */

.wiki-admin-nav {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.wiki-admin-nav-link {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 7px;
    transition: color 0.15s, border-color 0.15s;
}

.wiki-admin-nav-link:hover {
    color: var(--text);
    border-color: var(--accent);
}

.wiki-admin-nav-link.active {
    color: var(--accent);
    border-color: var(--accent);
}

.wiki-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.wiki-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.wiki-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.wiki-stat-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.wiki-admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

.wiki-admin-table-wrap {
    overflow-x: auto;
}

.wiki-admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.wiki-admin-table th {
    background: var(--bg);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

.wiki-admin-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

.wiki-admin-table tr:hover td {
    background: rgba(91, 127, 255, 0.04);
}

.wiki-user-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wiki-user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.wiki-user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.wiki-user-login {
    font-size: 12px;
    color: var(--muted);
    margin-left: 6px;
    font-family: var(--mono);
}

/* Admin settings */

.wiki-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
    user-select: none;
}

.wiki-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

/* ── Mobile responsive ────────────────────────────────────────────────────── */

@media (max-width: 600px) {
    /* Nav */
    .wiki-nav-links {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }

    .wiki-nav-link {
        padding: 10px 12px;
        font-size: 12px;
    }

    .wiki-nav-new {
        margin-left: 0;
    }

    /* Home grid: stack */
    .wiki-home-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* Article layout: stack sidebar below */
    .wiki-article-layout {
        grid-template-columns: 1fr;
    }

    .wiki-article-side {
        order: -1;
    }

    /* Editor: single column */
    .wiki-editor-split {
        grid-template-columns: 1fr;
    }

    .wiki-preview-pane {
        border-left: none;
        border-top: 1px solid var(--border);
        padding-left: 0;
        padding-top: 12px;
        min-height: 200px;
    }

    /* Admin: stack */
    .wiki-admin-grid {
        grid-template-columns: 1fr;
    }

    /* Profile: stack */
    .wiki-profile-grid {
        grid-template-columns: 1fr;
    }

    .wiki-profile-side {
        order: -1;
    }

    /* Stats: 2 columns */
    .wiki-stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Forms */
    .wiki-submit-btn {
        font-size: 16px;
    }

    .wiki-input,
    .wiki-select,
    .wiki-textarea {
        font-size: 16px !important;
    }

    /* Article meta: wrap */
    .wiki-article-meta {
        flex-direction: column;
        gap: 2px;
        white-space: normal;
    }

    .wiki-comment-date {
        margin-left: 0;
    }

    /* Table: scrollable */
    .wiki-article-body table {
        font-size: 12px;
    }

    /* Admin table: card layout */
    .wiki-admin-table thead {
        display: none;
    }

    .wiki-admin-table tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 8px;
        padding: 10px;
    }

    .wiki-admin-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4px 0;
        border-bottom: none;
        font-size: 12px;
    }

    .wiki-admin-table td::before {
        content: attr(data-label);
        font-size: 10px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--muted);
        margin-right: 8px;
    }

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

    .wiki-admin-table tr:hover td {
        background: none;
    }

    /* Breadcrumb */
    .wiki-breadcrumb {
        font-size: 12px;
    }

    /* Pagination */
    .wiki-pagination {
        justify-content: center;
    }

    /* Search */
    .wiki-search-row {
        flex-direction: column;
    }

    /* Form actions */
    .wiki-form-actions {
        flex-direction: column;
    }

    .wiki-form-actions a,
    .wiki-form-actions button {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    /* Admin nav */
    .wiki-admin-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}
