/* ============================================================
   Canja Wiki — identidade visual
   Paleta: Pink Canja primário, Bordô secundário, sistema de barras
   ============================================================ */

:root {
    /* Cores Canja */
    --pink-canja: #FF1A6B;
    --pink-dark: #C8004A;
    --pink-light: #FFD0E0;
    --pink-cream: #FFF5F0;

    --bordo: #5A1F1A;
    --brown-dark: #2C1311;
    --brown-deep: #1A0A09;

    --off-white: #FAF7F2;
    --paper: #FFFFFF;

    --text-primary: #1A0F0E;
    --text-secondary: #6B5454;
    --text-muted: #9E8A8A;

    --border: rgba(90, 31, 26, 0.12);
    --border-strong: rgba(90, 31, 26, 0.25);

    --success: #2E7D32;
    --warning: #ED6C02;
    --danger: #C62828;

    /* Tipografia */
    --font-display: 'Canja Typeface', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', Consolas, monospace;

    /* Layout */
    --sidebar-width: 260px;
    --radius: 8px;
    --shadow-sm: 0 1px 2px rgba(26, 10, 9, 0.08);
    --shadow-md: 0 4px 12px rgba(26, 10, 9, 0.10);
}

/* Importa fonte Canja se hospedada */
@font-face {
    font-family: 'Canja Typeface';
    src: url('/assets/fonts/canja-typeface.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text-primary);
    background: var(--off-white);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; }
h1 { font-size: 2rem; margin: 0 0 0.4em; }
h2 { font-size: 1.4rem; margin: 1.2em 0 0.6em; }
h3 { font-size: 1.1rem; margin: 1em 0 0.4em; }
p  { margin: 0 0 1em; }
a  { color: var(--pink-dark); text-decoration: none; transition: color .15s; }
a:hover { color: var(--pink-canja); }

code, pre { font-family: var(--font-mono); font-size: 0.9em; }
pre { background: var(--brown-deep); color: var(--pink-cream); padding: 1rem; border-radius: var(--radius); overflow-x: auto; }

/* ============================================================
   Layout
   ============================================================ */

.layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

.main {
    padding: 2rem 2.5rem 4rem;
    max-width: 1100px;
    width: 100%;
}

/* ============================================================
   Sidebar
   ============================================================ */

.sidebar {
    background: var(--brown-dark);
    color: var(--pink-cream);
    padding: 1.5rem 0 1rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header { padding: 0 1.25rem 1rem; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--pink-cream); font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; }
.brand:hover { color: var(--pink-canja); }
.brand-logo { width: 32px; height: 32px; }

.sidebar-search { padding: 0.9rem 1.25rem; }
.sidebar-search input {
    width: 100%;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.10);
    color: var(--pink-cream);
    padding: .5rem .75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
}
.sidebar-search input::placeholder { color: rgba(255,255,255,0.45); }
.sidebar-search input:focus { outline: none; border-color: var(--pink-canja); background: rgba(255,255,255,0.10); }

.sidebar-section { padding: 0.8rem 0; }
.sidebar-section h3 {
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 192, 203, 0.55);
    padding: 0 1.25rem;
    margin: 0 0 .35rem;
}

.sidebar-list { list-style: none; padding: 0; margin: 0; }
.sidebar-list a {
    display: block;
    padding: 0.45rem 1.25rem;
    color: var(--pink-cream);
    border-left: 3px solid transparent;
    font-size: 0.92rem;
    transition: background .15s, border-color .15s;
}
.sidebar-list a:hover { background: rgba(255, 255, 255, 0.05); }
.sidebar-list a.active { background: rgba(255, 26, 107, 0.18); border-left-color: var(--pink-canja); color: white; font-weight: 600; }

.sidebar-footer {
    margin-top: auto;
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: 0.85rem;
}
.user-chip { display: flex; align-items: center; gap: .5rem; flex: 1; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; }
.logout-link { color: rgba(255,192,203,0.65); font-size: 0.8rem; }
.logout-link:hover { color: var(--pink-canja); }

/* ============================================================
   Cards / Sections
   ============================================================ */

.page-header { margin-bottom: 1.5rem; }
.page-header .subtitle { color: var(--text-secondary); font-size: 0.95rem; margin: 0; }

.card {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.card.warn { border-left: 4px solid var(--warning); background: #FFFBF5; }

.empty { color: var(--text-muted); font-style: italic; }
.meta { color: var(--text-muted); font-size: 0.85rem; margin-left: 0.5rem; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .5rem; vertical-align: middle; }

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 100px;
    background: var(--pink-light);
    color: var(--pink-dark);
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: .5rem;
}

/* ============================================================
   Listas
   ============================================================ */

.recent-list, .approval-list, .page-list, .search-results, .member-list, .action-list {
    list-style: none; padding: 0; margin: 0;
}
.recent-list li, .approval-list li, .page-list li, .search-results li, .member-list li, .action-list li {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.recent-list li:last-child, .approval-list li:last-child, .page-list li:last-child, .search-results li:last-child, .member-list li:last-child, .action-list li:last-child { border-bottom: none; }

/* ============================================================
   Sector grid
   ============================================================ */

.sector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}
.sector-card {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    border-top: 4px solid var(--sector-color, var(--pink-canja));
    color: var(--text-primary);
    transition: transform .15s, box-shadow .15s;
}
.sector-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); color: var(--text-primary); }
.sector-card h3 { margin: 0 0 .3rem; color: var(--sector-color, var(--pink-canja)); }
.sector-card p { color: var(--text-secondary); font-size: 0.9rem; margin: 0; }

/* ============================================================
   Article (página de conteúdo)
   ============================================================ */

.article {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem 2.5rem;
    box-shadow: var(--shadow-sm);
}
.article-content {
    line-height: 1.7;
    font-size: 1rem;
}
.article-content h2, .article-content h3 { color: var(--bordo); }
.article-content img { max-width: 100%; height: auto; border-radius: var(--radius); }
.article-content figure { margin: 1.5rem 0; text-align: center; }
.article-content figcaption { font-size: 0.85rem; color: var(--text-muted); margin-top: .3rem; }
.article-content blockquote { border-left: 4px solid var(--pink-canja); padding-left: 1rem; color: var(--text-secondary); font-style: italic; margin: 1rem 0; }
.article-content .callout { padding: 0.8rem 1rem; border-radius: var(--radius); margin: 1rem 0; }
.article-content .callout.warning { background: #FFF6E0; border-left: 4px solid var(--warning); }

.article-footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.article-footer .article-meta p { margin: 0; color: var(--text-secondary); font-size: 0.9rem; }
.article-actions { display: flex; gap: 0.5rem; }

/* ============================================================
   Breadcrumb
   ============================================================ */

.breadcrumb {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .35rem;
}
.breadcrumb span { color: var(--text-muted); }

/* ============================================================
   Forms / Buttons
   ============================================================ */

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, color .15s, transform .05s;
    text-decoration: none;
}
.btn:hover { background: var(--pink-cream); color: var(--pink-dark); border-color: var(--pink-canja); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--pink-canja); color: white; border-color: var(--pink-canja); }
.btn-primary:hover { background: var(--pink-dark); color: white; border-color: var(--pink-dark); }
.btn.disabled { opacity: 0.4; pointer-events: none; }

.form-inline { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.form-inline input[type="email"], .form-inline input[type="text"] {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-size: 0.9rem;
    min-width: 220px;
}
.form-inline label { font-size: 0.9rem; color: var(--text-secondary); }

.search-form { display: flex; gap: 0.5rem; }
.search-form input { flex: 1; padding: 0.6rem; border: 1px solid var(--border-strong); border-radius: var(--radius); }

/* ============================================================
   Tabela
   ============================================================ */

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}
.data-table th, .data-table td {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.data-table th { font-weight: 600; color: var(--bordo); background: var(--pink-cream); }
.data-table tr:hover td { background: rgba(255, 26, 107, 0.04); }

.color-chip { display: inline-block; width: 16px; height: 16px; border-radius: 4px; vertical-align: middle; margin-right: .3rem; }

/* ============================================================
   Stats / Admin
   ============================================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--pink-canja);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.stat-value { font-family: var(--font-display); font-size: 2.2rem; font-weight: 700; color: var(--bordo); line-height: 1; }
.stat-label { color: var(--text-secondary); font-size: 0.85rem; }

/* ============================================================
   Roles e versões
   ============================================================ */

.role-badge {
    font-size: 0.7rem;
    padding: 0.1rem 0.5rem;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.role-reader { background: #ECEFF1; color: #455A64; }
.role-editor { background: #E3F2FD; color: #1565C0; }
.role-approver { background: #FFF3E0; color: #E65100; }
.role-sector_admin { background: #F3E5F5; color: #6A1B9A; }

.avatar { width: 24px; height: 24px; border-radius: 50%; vertical-align: middle; }

.version-list { list-style: none; padding: 0; margin: 0; }
.version-item { padding: 0.8rem 0; border-bottom: 1px solid var(--border); }
.version-item.status-pending { border-left: 3px solid var(--warning); padding-left: 0.8rem; }
.version-item.status-rejected { border-left: 3px solid var(--danger); padding-left: 0.8rem; }
.version-item.status-approved { border-left: 3px solid var(--success); padding-left: 0.8rem; }
.version-header { display: flex; align-items: center; gap: .5rem; }
.status-badge { text-transform: uppercase; font-size: 0.7rem; }

/* ============================================================
   Auth page
   ============================================================ */

.auth-page {
    background: linear-gradient(140deg, var(--bordo) 0%, var(--brown-deep) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.auth-card {
    background: var(--paper);
    border-radius: 16px;
    padding: 2.5rem 3rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 380px;
    width: 100%;
    text-align: center;
}
.auth-logo { width: 56px; height: 56px; margin: 0 auto 1rem; display: block; }
.auth-card h1 { font-size: 1.6rem; margin: 0 0 .2rem; color: var(--bordo); }
.auth-subtitle { color: var(--text-secondary); margin-bottom: 1.5rem; }
.auth-footer { margin-top: 1.5rem; font-size: 0.8rem; color: var(--text-muted); }
.g_id_signin { display: flex; justify-content: center; margin: 1rem 0; }

.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.9rem; }
.alert-error { background: #FFEBEE; color: var(--danger); border: 1px solid #FFCDD2; }
.alert-success { background: #E8F5E9; color: var(--success); border: 1px solid #C8E6C9; }

/* ============================================================
   Erro
   ============================================================ */

.error-page { text-align: center; padding: 4rem 1rem; }
.error-page h1 { font-size: 6rem; color: var(--pink-canja); margin: 0; }
.error-page p { color: var(--text-secondary); margin-bottom: 2rem; }

/* ============================================================
   Mobile
   ============================================================ */

@media (max-width: 800px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: relative;
        height: auto;
        max-height: none;
    }
    .main { padding: 1rem; }
    .article { padding: 1.5rem; }
}

/* ============================================================
   Features novas: search modal, editor, diff, directory, toc
   ============================================================ */

/* Search trigger e modal */
.search-trigger {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.10);
    color: rgba(255,255,255,0.65);
    padding: 0.45rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
}
.search-trigger:hover { background: rgba(255,255,255,0.10); color: var(--pink-cream); }
.search-trigger kbd {
    background: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.6);
    font-family: var(--font-mono);
}

.search-overlay {
    position: fixed; inset: 0;
    background: rgba(26, 10, 9, 0.55);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex; justify-content: center; padding-top: 12vh;
}
.search-overlay[hidden] { display: none; }
.search-modal {
    width: min(640px, 92vw);
    background: var(--paper);
    border-radius: 14px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.4);
    overflow: hidden;
    height: fit-content;
}
.search-modal input[type=search] {
    width: 100%; padding: 1.1rem 1.4rem;
    border: none; border-bottom: 1px solid var(--border);
    font-size: 1.05rem; outline: none;
}
.search-results { max-height: 60vh; overflow-y: auto; }
.search-result {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.7rem 1.4rem; cursor: pointer;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary); text-decoration: none;
}
.search-result.selected, .search-result:hover { background: var(--pink-cream); }
.search-result-title { flex: 1; font-weight: 500; }
.search-result-sector { color: var(--text-muted); font-size: 0.85rem; }
.search-empty { padding: 1.5rem; color: var(--text-muted); text-align: center; }
.search-footer {
    padding: 0.6rem 1.4rem; border-top: 1px solid var(--border);
    display: flex; gap: 1rem; font-size: 0.75rem; color: var(--text-muted);
}
.search-footer kbd {
    background: var(--off-white); padding: 2px 5px; border-radius: 3px;
    border: 1px solid var(--border-strong); font-family: var(--font-mono);
    font-size: 0.7rem;
}

/* Editor */
.editor-shell {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem 2.5rem;
    box-shadow: var(--shadow-sm);
}
.editor-title {
    width: 100%;
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    border: none; outline: none;
    padding: 0.4rem 0;
    margin-bottom: 0.8rem;
    border-bottom: 2px solid var(--border);
}
.editor-title:focus { border-bottom-color: var(--pink-canja); }
.editor-body { min-height: 60vh; }
.editor-toolbar {
    margin-top: 1.5rem; padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.editor-toolbar .btn-primary { margin-left: auto; }
.editor-checkbox { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; color: var(--text-secondary); }
.editor-status { color: var(--text-muted); font-size: 0.85rem; }

/* Review diff */
.review-diff {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 1rem; margin-bottom: 1.5rem;
}
.diff-pane {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    max-height: 70vh; overflow-y: auto;
}
.diff-pane h3 {
    margin-top: 0;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
}
.diff-new { border-color: var(--pink-canja); box-shadow: 0 0 0 2px rgba(255, 26, 107, 0.12); }
.diff-new h3 { color: var(--pink-dark); }

@media (max-width: 900px) {
    .review-diff { grid-template-columns: 1fr; }
}

/* Directory (Quem é quem) */
.directory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}
.directory-card {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
}
.directory-avatar {
    width: 72px; height: 72px; border-radius: 50%;
    margin: 0 auto 0.6rem; display: block;
    object-fit: cover; border: 2px solid var(--pink-cream);
}
.directory-avatar-placeholder {
    background: var(--pink-cream);
    color: var(--pink-dark);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; font-size: 1.5rem;
}
.directory-card h3 { margin: 0; font-size: 1rem; }
.directory-email { color: var(--text-muted); font-size: 0.8rem; margin: 0.2rem 0; }
.directory-sectors { color: var(--text-secondary); font-size: 0.85rem; margin: 0.4rem 0 0; }
.badge-admin { background: var(--bordo); color: white; margin-top: 0.4rem; }

/* TOC */
.page-toc {
    float: right; max-width: 240px; margin: 0 0 1rem 1.5rem;
    background: var(--pink-cream); border-left: 3px solid var(--pink-canja);
    padding: 0.8rem 1rem; border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 0.85rem;
}
.page-toc h4 { margin: 0 0 0.4rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--bordo); }
.page-toc ul { list-style: none; padding: 0; margin: 0; }
.page-toc li { margin: 0.2rem 0; }
.page-toc li.lvl-h3 { padding-left: 0.8rem; }
.page-toc a { color: var(--text-secondary); }
.page-toc a:hover { color: var(--pink-dark); }
.reading-time { color: var(--text-muted); font-size: 0.8rem; margin-left: 0.6rem; font-style: italic; }

/* Approval list extras */
.approval-title { font-weight: 500; flex: 1; }

/* Sidebar tree */
.sidebar-tree { max-height: 320px; overflow-y: auto; }
.page-tree li.depth-1 a { padding-left: 2rem; font-size: 0.85rem; opacity: 0.85; }
.page-tree li.depth-2 a { padding-left: 2.6rem; font-size: 0.8rem; opacity: 0.75; }
.page-tree li.active a { background: rgba(255, 26, 107, 0.15); border-left-color: var(--pink-canja); }

/* Botão apagar página (admin) */
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #a31f1f; color: white; border-color: #a31f1f; }
.inline-form { display: inline-flex; align-items: center; gap: 0.4rem; }
.hard-delete-toggle { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.75rem; color: var(--text-muted); cursor: pointer; }
.hard-delete-toggle input { cursor: pointer; }
