/* ═══════════════════════════════════════
   hype.media Wiki - CSS
   ═══════════════════════════════════════ */

:root {
    /* Light Mode */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --bg-sidebar: #f1f3f5;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-code: #f4f5f7;
    --text-primary: #1a1a2e;
    --text-secondary: #495057;
    --text-muted: #868e96;
    --text-link: #4263eb;
    --text-link-hover: #364fc7;
    --border-color: #dee2e6;
    --border-light: #e9ecef;
    --accent: #4263eb;
    --accent-hover: #364fc7;
    --accent-light: #dbe4ff;
    --success: #2b8a3e;
    --success-bg: #d3f9d8;
    --danger: #c92a2a;
    --danger-bg: #ffe3e3;
    --warning: #e67700;
    --warning-bg: #fff3bf;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --sidebar-width: 280px;
    --header-height: 56px;
    --radius: 6px;
    --radius-lg: 10px;
    --transition: 0.2s ease;
}

[data-theme="dark"] {
    --bg-primary: #1a1b2e;
    --bg-secondary: #16172b;
    --bg-tertiary: #2a2b3d;
    --bg-sidebar: #141525;
    --bg-card: #1e1f33;
    --bg-input: #252640;
    --bg-code: #2a2b3d;
    --text-primary: #e4e5f1;
    --text-secondary: #a9adc1;
    --text-muted: #6c6f85;
    --text-link: #748ffc;
    --text-link-hover: #91a7ff;
    --border-color: #2e2f45;
    --border-light: #252640;
    --accent: #748ffc;
    --accent-hover: #91a7ff;
    --accent-light: #2b2d5e;
    --success: #51cf66;
    --success-bg: #1a3a1a;
    --danger: #ff6b6b;
    --danger-bg: #3a1a1a;
    --warning: #ffd43b;
    --warning-bg: #3a351a;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.4);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
}

a { color: var(--text-link); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--text-link-hover); }

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

/* ── Header ── */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
    transition: background var(--transition), border-color var(--transition);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
    min-width: var(--sidebar-width);
}

.header-brand svg { width: 28px; height: 28px; color: var(--accent); }

.header-search {
    flex: 1;
    max-width: 500px;
    margin: 0 20px;
}

.header-search form {
    display: flex;
    position: relative;
}

.header-search input {
    width: 100%;
    padding: 8px 14px 8px 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color var(--transition), background var(--transition);
}

.header-search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.header-search .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 18px;
    height: 18px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* ── Theme Toggle ── */
.theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 6px 10px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    transition: all var(--transition);
}

.theme-toggle:hover {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
}

.theme-toggle svg { width: 16px; height: 16px; }

/* ── User Menu ── */
.user-menu {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.85rem;
    transition: all var(--transition);
}

.user-menu-btn:hover { border-color: var(--accent); }

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
}

.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    z-index: 1001;
    overflow: hidden;
}

.user-dropdown.show { display: block; }

.user-dropdown a, .user-dropdown button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    border: none;
    background: none;
    width: 100%;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background var(--transition);
    text-align: left;
}

.user-dropdown a:hover, .user-dropdown button:hover {
    background: var(--bg-tertiary);
}

.dropdown-divider {
    border-top: 1px solid var(--border-color);
    margin: 4px 0;
}

/* ── Sidebar ── */
.app-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 16px 0;
    z-index: 100;
    transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.sidebar-section {
    padding: 0 12px;
    margin-bottom: 20px;
}

.sidebar-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0 8px;
    margin-bottom: 6px;
    font-weight: 600;
}

/* ── Page Tree ── */
.page-tree { list-style: none; }

.page-tree li { position: relative; }

.page-tree-item {
    display: flex;
    align-items: center;
    padding: 5px 8px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.88rem;
    transition: all var(--transition);
    gap: 4px;
    cursor: pointer;
}

.page-tree-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.page-tree-item.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 500;
}

.tree-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    flex-shrink: 0;
    border-radius: 3px;
    transition: all var(--transition);
}

.tree-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.tree-toggle svg {
    width: 14px;
    height: 14px;
    transition: transform var(--transition);
}

.tree-toggle.expanded svg {
    transform: rotate(90deg);
}

.tree-spacer { width: 20px; flex-shrink: 0; }

.page-tree-item .page-icon {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.page-tree .subtree {
    display: none;
    padding-left: 12px;
}

.page-tree .subtree.open { display: block; }

/* ── Main Content ── */
.app-main {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 24px 32px;
    flex: 1;
    min-width: 0;
}

/* ── Breadcrumb ── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text-link); }
.breadcrumb-sep { color: var(--border-color); }

/* ── Page Content ── */
.page-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 8px;
}

.page-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.82rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.page-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-meta-item svg { width: 14px; height: 14px; }

.page-body {
    max-width: 900px;
    line-height: 1.7;
    font-size: 0.95rem;
}

.page-body h1, .page-body h2, .page-body h3, .page-body h4, .page-body h5, .page-body h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
    line-height: 1.3;
}

.page-body h1 { font-size: 1.6rem; }
.page-body h2 { font-size: 1.35rem; }
.page-body h3 { font-size: 1.15rem; }

.page-body p { margin-bottom: 1em; }

.page-body ul, .page-body ol {
    margin-bottom: 1em;
    padding-left: 1.5em;
}

.page-body li { margin-bottom: 0.3em; }

.page-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
    font-size: 0.9rem;
}

.page-body table th, .page-body table td {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.page-body table th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.page-body table tr:hover td {
    background: var(--bg-secondary);
}

.page-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    margin: 8px 0;
}

.page-body pre {
    background: var(--bg-code);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 14px;
    overflow-x: auto;
    margin-bottom: 1em;
    font-size: 0.85rem;
    line-height: 1.5;
}

.page-body code {
    background: var(--bg-code);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.88em;
}

.page-body pre code { background: none; padding: 0; }

.page-body blockquote {
    border-left: 4px solid var(--accent);
    padding: 12px 16px;
    margin: 0 0 1em;
    background: var(--bg-secondary);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-secondary);
}

/* Confluence macro styling */
.page-body .confluence-information-macro,
.page-body .conf-macro {
    padding: 12px 16px;
    margin: 12px 0;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 20px; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: white;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}
.btn-secondary:hover {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger);
}
.btn-danger:hover { opacity: 0.85; }

.btn-sm { padding: 5px 10px; font-size: 0.82rem; }
.btn-icon { padding: 6px; }

/* ── Forms ── */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.92rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

select.form-control {
    appearance: auto;
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
    font-family: inherit;
}

/* ── Alerts ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning); }

/* ── Labels/Tags ── */
.label-tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    transition: all var(--transition);
}

.label-tag:hover {
    background: var(--accent);
    color: white;
}

.labels-list {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

/* ── Children ── */
.children-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.child-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: all var(--transition);
    color: var(--text-primary);
}

.child-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
}

.child-card svg { width: 20px; height: 20px; color: var(--accent); flex-shrink: 0; }

/* ── Attachments ── */
.attachments-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 8px;
    transition: all var(--transition);
}

.attachment-item:hover {
    border-color: var(--accent);
    background: var(--bg-secondary);
}

.attachment-icon { width: 20px; height: 20px; color: var(--text-muted); flex-shrink: 0; }
.attachment-name { flex: 1; font-size: 0.9rem; }
.attachment-size { font-size: 0.8rem; color: var(--text-muted); }

/* ── Comments ── */
.comments-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.comment {
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 12px;
    background: var(--bg-card);
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.comment-author { font-weight: 600; color: var(--text-primary); }
.comment-date { color: var(--text-muted); }
.comment-body { font-size: 0.92rem; line-height: 1.6; }

/* ── Dashboard ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-light);
    color: var(--accent);
}

.stat-icon svg { width: 22px; height: 22px; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }

.recent-list { list-style: none; }

.recent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}

.recent-item:last-child { border-bottom: none; }
.recent-item svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.recent-item-meta { font-size: 0.8rem; color: var(--text-muted); margin-left: auto; white-space: nowrap; }

/* ── Admin Tables ── */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tr:hover td { background: var(--bg-secondary); }

.role-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.role-admin { background: #ffe3e3; color: #c92a2a; }
.role-editor { background: #dbe4ff; color: #364fc7; }
.role-viewer { background: #d3f9d8; color: #2b8a3e; }

[data-theme="dark"] .role-admin { background: #3a1a1a; color: #ff6b6b; }
[data-theme="dark"] .role-editor { background: #2b2d5e; color: #91a7ff; }
[data-theme="dark"] .role-viewer { background: #1a3a1a; color: #51cf66; }

.status-active { color: var(--success); }
.status-inactive { color: var(--danger); }

/* ── Login Page ── */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: var(--bg-secondary);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-top: 12px;
}

.login-logo svg { width: 48px; height: 48px; color: var(--accent); }

.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ── Versions ── */
.version-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 8px;
    background: var(--bg-card);
}

.version-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.version-info { flex: 1; }
.version-info .editor { font-weight: 500; }
.version-info .date { font-size: 0.82rem; color: var(--text-muted); }
.version-info .comment { font-size: 0.85rem; color: var(--text-secondary); margin-top: 2px; }

/* ── Editor ── */
.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

/* ── Search Results ── */
.search-result {
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 12px;
    background: var(--bg-card);
    transition: all var(--transition);
}

.search-result:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.search-result h3 { font-size: 1.05rem; margin-bottom: 4px; }
.search-result .search-excerpt {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-top: 4px;
}
.search-result .search-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ── Activity Log ── */
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.88rem;
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-time {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 0.95rem; }

/* ── 404 ── */
.error-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
}

.error-page h1 { font-size: 4rem; color: var(--text-muted); }
.error-page p { color: var(--text-secondary); margin-top: 8px; }

/* ── Sidebar Toggle (Mobile) ── */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
    margin-right: 8px;
}

.sidebar-toggle svg { width: 24px; height: 24px; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar-toggle { display: flex; }

    .app-sidebar {
        transform: translateX(-100%);
        z-index: 999;
        box-shadow: var(--shadow-lg);
    }

    .app-sidebar.open { transform: translateX(0); }

    .app-main {
        margin-left: 0;
        padding: 16px;
    }

    .header-brand { min-width: auto; }
    .header-search { display: none; }

    .page-header h1 { font-size: 1.4rem; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .children-list { grid-template-columns: 1fr; }
}

/* ── Sidebar overlay for mobile ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
}

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

/* ── Page Actions ── */
.page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Toolbar for page view ── */
.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

/* ── Upload form ── */
.upload-form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.upload-form input[type="file"] {
    font-size: 0.85rem;
}

/* ── Confluence specific content styling ── */
.page-body ac\:structured-macro,
.page-body ac\:rich-text-body {
    display: block;
}

.page-body ri\:attachment {
    display: none;
}

/* ══════════════════════════════════════════
   NEW FEATURES
   ══════════════════════════════════════════ */

/* ── Command Palette ── */
#command-palette { display: none; position: fixed; inset: 0; z-index: 9999; }
#command-palette.open { display: flex; align-items: flex-start; justify-content: center; padding-top: 15vh; }

.cp-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.cp-dialog {
    position: relative;
    width: 580px;
    max-width: 90vw;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.cp-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
}

.cp-input-wrap input {
    flex: 1;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
}

.cp-input-wrap kbd {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: inherit;
}

.cp-results {
    max-height: 360px;
    overflow-y: auto;
}

.cp-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-primary);
    transition: background var(--transition);
    cursor: pointer;
    text-decoration: none;
}

.cp-item:hover, .cp-item.selected {
    background: var(--accent-light);
    color: var(--text-primary);
}

.cp-item svg { color: var(--text-muted); flex-shrink: 0; }
.cp-item-title { font-size: 0.92rem; font-weight: 500; }
.cp-item-meta { font-size: 0.78rem; color: var(--text-muted); }
.cp-empty { padding: 24px 16px; text-align: center; color: var(--text-muted); font-size: 0.9rem; }

.cp-footer {
    display: flex;
    gap: 16px;
    padding: 10px 16px;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.cp-footer kbd {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 0.7rem;
    font-family: inherit;
}

/* ── Favorites ── */
.favorite-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 6px 10px;
    cursor: pointer;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    transition: all var(--transition);
}

.favorite-btn:hover { border-color: #f59f00; color: #f59f00; }
.favorite-btn.favorited { color: #f59f00; border-color: #f59f00; }
.favorite-btn svg { width: 16px; height: 16px; }

/* ── Table of Contents ── */
.toc-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 24px;
}

.toc-title {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-list li {
    margin: 0;
}

.toc-list a {
    display: block;
    padding: 3px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: color var(--transition);
}

.toc-list a:hover { color: var(--accent); }

/* ── Lightbox ── */
#lightbox { display: none; position: fixed; inset: 0; z-index: 9998; }
#lightbox.open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lb-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(8px);
}

.lb-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.lb-content img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.lb-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 32px;
    height: 32px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-primary);
    transition: all var(--transition);
}

.lb-close:hover { background: var(--danger-bg); color: var(--danger); }

.lb-caption {
    text-align: center;
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
    margin-top: 10px;
}

/* ── Code Copy Button ── */
.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 6px;
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0;
    transition: all var(--transition);
}

pre:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ── Drag & Drop Upload ── */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 12px;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}

.drop-zone svg { width: 32px; height: 32px; margin-bottom: 8px; opacity: 0.6; }

.drop-zone input[type="file"] { display: none; }

.drop-preview { margin-top: 12px; text-align: left; }

.drop-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    margin-bottom: 4px;
    font-size: 0.85rem;
}

.drop-file-name { font-weight: 500; }
.drop-file-status { font-size: 0.78rem; }
.drop-file-status.uploading { color: var(--accent); }
.drop-file-status.done { color: var(--success); }
.drop-file-status.error { color: var(--danger); }

/* ── Toast Notifications ── */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 10px 18px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    transform: translateX(120%);
    transition: transform 0.3s ease;
}

.toast.show { transform: translateX(0); }
.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }

/* ── Shortcuts Help ── */
#shortcuts-help { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; }

.shortcuts-dialog {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    min-width: 320px;
}

.shortcuts-dialog h3 { margin-bottom: 16px; }

.shortcuts-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
    align-items: center;
    font-size: 0.9rem;
}

.shortcuts-grid kbd {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.78rem;
    font-family: inherit;
}

/* ── Keyboard hint in header search ── */
.search-kbd {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.7rem;
    color: var(--text-muted);
    pointer-events: none;
}

/* ── Dashboard Columns ── */
.dashboard-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.dashboard-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dashboard-columns .card-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dashboard-columns .card-header svg {
    flex-shrink: 0;
}

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

/* ── Template Picker ── */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.template-card {
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-card);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}

.template-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.template-card.selected {
    border-color: var(--accent);
    background: var(--accent-light);
}

.template-card svg { width: 28px; height: 28px; color: var(--accent); margin-bottom: 8px; }
.template-card h4 { font-size: 0.92rem; margin-bottom: 2px; }
.template-card p { font-size: 0.78rem; color: var(--text-muted); }

/* ── Favorites section in sidebar ── */
.sidebar-favorites {
    list-style: none;
    padding: 0;
}

.sidebar-favorites li a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.sidebar-favorites li a:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-favorites li a svg { width: 14px; height: 14px; color: #f59f00; flex-shrink: 0; }
