/* ═══════════════════════════════════════════════════
   Claw Knowledge System — Public CSS (Light Theme)
   Prefix: ck-pub- (public), ck- (shared), cw- (shell)
   Research-reading optimized: warm paper, high contrast text

   To switch themes, change $cssFiles in theclaw/index.php:
     Dark:  'claw-knowledge-public.css'
     Light: 'claw-knowledge-public-light.css'
   ═══════════════════════════════════════════════════ */


/* ── Body Override ───────────────────────────────── */
body.claw-page {
    background: #f7f8f6;
    color: #374151;
}

body.claw-page #main,
body.claw-page main {
    background: transparent;
}


/* ── Navigation Override ─────────────────────────── */
body.claw-page .cw-navbar {
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

body.claw-page .cw-brand-icon {
    color: #0d9488;
}

body.claw-page .cw-brand-text {
    color: #1e293b;
}

body.claw-page .cw-nav-link {
    color: #64748b !important;
}

body.claw-page .cw-nav-link:hover {
    color: #0d9488 !important;
    background: rgba(13, 148, 136, 0.06);
}

body.claw-page .cw-nav-home {
    color: #94a3b8 !important;
}

body.claw-page .cw-nav-home:hover {
    color: #64748b !important;
}

body.claw-page .cw-nav-divider {
    background: #e5e7eb;
}

body.claw-page .cw-navbar-toggler {
    border-color: #e5e7eb;
}

body.claw-page .cw-navbar-toggler .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%2364748b' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

@media (max-width: 991px) {
    body.claw-page .navbar-collapse { background: #ffffff; }
}


/* ── Hero ─────────────────────────────────────────── */
.ck-hero {
    background: linear-gradient(135deg, #0f172a 0%, #134e4a 50%, #0f172a 100%);
    padding: 60px 20px;
    text-align: center;
    margin: -20px -15px 0;
    border-bottom: 1px solid #e5e7eb;
}

.ck-hero-inner {
    max-width: 800px;
    margin: 0 auto;
}

.ck-hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: #f1f5f9;
    margin: 0 0 12px;
    letter-spacing: -0.02em;
}

.ck-hero-subtitle {
    font-size: 1.1rem;
    color: #94a3b8;
    line-height: 1.6;
    margin: 0 0 32px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.ck-hero-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    flex-wrap: wrap;
}

.ck-hero-stat {
    text-align: center;
}

.ck-hero-stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #2dd4bf;
}

.ck-hero-stat-label {
    font-size: 0.75rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}


/* ── Wrapper ──────────────────────────────────────── */
.ck-pub-wrapper {
    max-width: 1100px;
    margin: 24px auto 0;
    padding: 0 16px;
}

.ck-pub-wrapper-fluid {
    max-width: 100%;
    margin: 24px auto 0;
    padding: 0 16px;
}


/* ── Search Bar ───────────────────────────────────── */
.ck-pub-search-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 24px;
}

.ck-pub-search-wrapper {
    flex: 1;
    position: relative;
}

.ck-pub-search-wrapper > i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

.ck-pub-search-input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    color: #1e293b;
    font-size: 0.95rem;
}

.ck-pub-search-input:focus {
    outline: none;
    border-color: #0d9488;
    box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.12);
}

.ck-pub-search-input::placeholder {
    color: #9ca3af;
}

.ck-pub-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    margin-top: 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.ck-pub-search-result {
    display: block;
    padding: 10px 14px;
    color: #1e293b;
    text-decoration: none;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.9rem;
}

.ck-pub-search-result:hover {
    background: #f0fdfa;
    color: #0d9488;
}

.ck-pub-search-result-type {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: #94a3b8;
    margin-right: 8px;
    letter-spacing: 0.05em;
}

.ck-pub-admin-link {
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 1rem;
}

.ck-pub-admin-link:hover {
    color: #0d9488;
    border-color: #0d9488;
}


/* ── Main Layout (tree + sidebar) ─────────────────── */
.ck-pub-main {
    display: flex;
    gap: 32px;
}

.ck-pub-tree-section {
    flex: 1;
    min-width: 0;
}

.ck-pub-sidebar {
    width: 300px;
    flex-shrink: 0;
}


/* ── Section Titles ───────────────────────────────── */
.ck-pub-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
}

/* ── Secondary Tree Block ─────────────────────────── */
.ck-pub-secondary-block {
    padding-top: 30px;
}


/* ── Public Tree ──────────────────────────────────── */
.ck-pub-tree, .ck-pub-tree-root {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ck-pub-tree .ck-pub-tree {
    padding-left: 24px;
}

.ck-pub-item {
    margin-bottom: 0;
}

.ck-pub-item.ck-collapsed > .ck-pub-tree {
    display: none;
}

.ck-pub-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 6px;
    transition: background 0.15s;
}

.ck-pub-row:hover {
    background: #f0fdfa;
}

.ck-pub-toggle {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 2px;
    font-size: 0.8rem;
    transition: transform 0.15s;
    width: 22px;
    text-align: center;
}

.ck-expanded > .ck-pub-row > .ck-pub-toggle > i {
    transform: rotate(90deg);
    display: inline-block;
}

.ck-pub-toggle-spacer {
    width: 22px;
    display: inline-block;
}

.ck-pub-title {
    color: #1e293b;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    flex: 1;
}

.ck-pub-title:hover {
    color: #0d9488;
}

.ck-pub-count {
    font-size: 0.7rem;
    background: rgba(13, 148, 136, 0.35);
    color: #0d9488;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 15px;
    font-weight: 600;
}

.ck-pub-count-docs {
    font-size: 0.7rem;
    background: rgba(59, 130, 246, 0.08);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.25);
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: 6px;
}

.ck-pub-item.ck-active > .ck-pub-row {
    background: rgba(13, 148, 136, 0.06);
}

.ck-pub-item.ck-active > .ck-pub-row > .ck-pub-title {
    color: #0d9488;
}


/* ── Sidebar ──────────────────────────────────────── */
.ck-pub-sidebar-section {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.ck-pub-sidebar-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 10px;
}

.ck-pub-sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    color: #64748b;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: background 0.15s;
}

.ck-pub-sidebar-link:hover {
    background: #f0fdfa;
    color: #0d9488;
}

/* Tree Key */
.ck-pub-tree-key {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ck-pub-key-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #64748b;
}

.ck-pub-key-item i {
    font-size: 0.7rem;
    color: #94a3b8;
    width: 20px;
    text-align: center;
}

.ck-pub-key-item .ck-pub-count {
    flex-shrink: 0;
}

.ck-pub-findings {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ck-pub-findings li {
    padding: 6px 0;
    font-size: 0.8rem;
    color: #64748b;
    line-height: 1.5;
    border-bottom: 1px solid #f1f5f9;
}

.ck-pub-findings li:last-child {
    border-bottom: none;
}

.ck-pub-findings strong {
    color: #0d9488;
}

.ck-pub-sidebar-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ck-pub-sidebar-stats div {
    font-size: 0.8rem;
    color: #64748b;
}

.ck-pub-sidebar-stats span {
    font-weight: 700;
    color: #0d9488;
    margin-right: 4px;
}


/* ── Breadcrumb ───────────────────────────────────── */
.ck-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.ck-breadcrumb-item {
    color: #64748b;
    text-decoration: none;
    font-size: 0.85rem;
}

a.ck-breadcrumb-item:hover {
    color: #0d9488;
}

.ck-breadcrumb-current {
    color: #1e293b;
    font-weight: 500;
}

.ck-breadcrumb-sep {
    color: #cbd5e1;
    font-size: 0.7rem;
}


/* ── Node Detail ──────────────────────────────────── */
.ck-pub-node-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 8px;
}

.ck-pub-node-desc {
    color: #64748b;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 24px;
}


/* ── Cards Grid ───────────────────────────────────── */
.ck-pub-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}

.ck-pub-card {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    text-decoration: none;
    transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}

.ck-pub-card:hover {
    border-color: #0d9488;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.ck-pub-card-icon {
    color: #0d9488;
    font-size: 1.3rem;
    margin-top: 2px;
}

.ck-pub-card-title {
    color: #1e293b;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.ck-pub-card-meta {
    font-size: 0.75rem;
    color: #94a3b8;
}

.ck-pub-card-desc {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 4px;
    line-height: 1.4;
}


/* ── Document List (in node detail) ───────────────── */
.ck-pub-doc-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ck-pub-doc-card {
    display: flex;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.15s;
}

.ck-pub-doc-card:hover {
    background: #f0fdfa;
}

.ck-pub-doc-card-icon {
    color: #94a3b8;
    font-size: 1rem;
    margin-top: 2px;
}

.ck-pub-doc-card-title {
    color: #1e293b;
    font-size: 0.9rem;
    font-weight: 500;
}

.ck-pub-doc-card-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 3px;
    font-size: 0.75rem;
    color: #94a3b8;
    flex-wrap: wrap;
}

.ck-pub-doc-badge {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 10px;
}


/* ── Document Viewer ──────────────────────────────── */
.ck-pub-doc {
    max-width: 800px;
}

.ck-pub-doc-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.ck-pub-doc-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 10px;
}

.ck-pub-doc-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.ck-pub-doc-type, .ck-pub-doc-words, .ck-pub-doc-date {
    font-size: 0.8rem;
    color: #94a3b8;
}

.ck-pub-doc-content {
    color: #374151;
    font-size: 0.95rem;
    line-height: 1.8;
}

.ck-pub-doc-content h1,
.ck-pub-doc-content h2,
.ck-pub-doc-content h3,
.ck-pub-doc-content h4 {
    color: #1e293b;
    margin-top: 28px;
    margin-bottom: 10px;
}

.ck-pub-doc-content h1 { font-size: 1.4rem; }
.ck-pub-doc-content h2 { font-size: 1.2rem; }
.ck-pub-doc-content h3 { font-size: 1.05rem; }

.ck-pub-doc-content pre {
    background: #f8fafc;
    padding: 14px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.85rem;
    border: 1px solid #e5e7eb;
}

.ck-pub-doc-content code {
    background: #f1f5f9;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 0.85em;
    color: #0f766e;
}

.ck-pub-doc-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.ck-pub-doc-content a {
    color: #0d9488;
    text-decoration: underline;
    text-decoration-color: rgba(13, 148, 136, 0.3);
    text-underline-offset: 2px;
}

.ck-pub-doc-content a:hover {
    color: #0f766e;
    text-decoration-color: #0f766e;
}

.ck-pub-doc-content strong { color: #1e293b; }

.ck-pub-doc-content ul {
    padding-left: 20px;
}

.ck-pub-doc-content li {
    margin-bottom: 4px;
}


/* ── Shared Badges ────────────────────────────────── */
.ck-status-draft { background: rgba(245, 158, 11, 0.1); color: #d97706; }
.ck-status-review { background: rgba(99, 102, 241, 0.1); color: #6366f1; }
.ck-status-final { background: rgba(13, 148, 136, 0.1); color: #0d9488; }
.ck-status-archived { background: rgba(107, 114, 128, 0.1); color: #6b7280; }

.ck-conf-high { background: rgba(13, 148, 136, 0.1); color: #0d9488; }
.ck-conf-medium { background: rgba(245, 158, 11, 0.1); color: #d97706; }
.ck-conf-low { background: rgba(239, 68, 68, 0.1); color: #dc2626; }
.ck-conf-unverified { background: rgba(107, 114, 128, 0.1); color: #6b7280; }


/* ── Tables ───────────────────────────────────────── */
.ck-table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
    font-size: 0.85rem;
}

.ck-table th, .ck-table td {
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    text-align: left;
}

.ck-table th {
    background: #f8fafc;
    color: #1e293b;
    font-weight: 600;
}

.ck-table td a {
    color: #0d9488;
    text-decoration: none;
    word-break: break-all;
}

.ck-table td a:hover {
    color: #0f766e;
    text-decoration: underline;
}

/* ── Depth Badges (universal) ────────────────────── */
.ck-depth-badge {
    display: inline-block;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0 6px;
    margin-left: 4px;
    vertical-align: middle;
}

.ck-depth-nodes {
    background: #dbeafe;
    color: #1e40af;
}

.ck-depth-docs {
    background: #d1fae5;
    color: #065f46;
}

/* ── Inline Overview Documents ───────────────────── */
.ck-pub-doc-inline {
    margin-bottom: 2rem;
}

.ck-pub-doc-inline .ck-pub-doc-content {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1.5rem;
    overflow-x: auto;
}

/* Tables inside inline docs: fit container, scroll if needed */
.ck-pub-doc-inline .ck-table {
    width: 100%;
    font-size: 0.8rem;
}

.ck-pub-doc-inline .ck-table th {
    white-space: nowrap;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: #f1f5f9;
    color: #475569;
    padding: 8px 10px;
}

.ck-pub-doc-inline .ck-table td {
    vertical-align: top;
    font-size: 0.8rem;
    line-height: 1.5;
    padding: 8px 10px;
    word-break: break-word;
}

.ck-pub-doc-inline .ck-table tr:hover td {
    background: #f8fafc;
}

.ck-pub-doc-inline .ck-table tr:hover td:first-child {
    background: #f1f5f9;
}


/* ── Footer Override ─────────────────────────────── */
body.claw-page #footer.cw-footer {
    background: #1e293b;
    border-top: 1px solid #334155;
}

body.claw-page .cw-footer-icon {
    color: #2dd4bf;
}

body.claw-page .cw-footer-name {
    color: #e2e8f0;
}

body.claw-page .cw-footer-tagline {
    color: #94a3b8;
}

body.claw-page .cw-footer-links {
    border-color: #334155;
}

body.claw-page .cw-footer-links a {
    color: #94a3b8;
}

body.claw-page .cw-footer-links a:hover {
    color: #2dd4bf;
}

body.claw-page .cw-footer-bottom p {
    color: #475569;
}


/* ── Responsive ───────────────────────────────────── */
@media (max-width: 768px) {
    .ck-hero { padding: 40px 16px; }
    .ck-hero-title { font-size: 1.8rem; }
    .ck-hero-stats { gap: 16px; }

    .ck-pub-main {
        flex-direction: column;
    }

    .ck-pub-sidebar {
        width: 100%;
    }

    .ck-pub-card-grid {
        grid-template-columns: 1fr;
    }
}

/* ═══════════════════════════════════════════════
   Custom Page: Existing Projects Table
   ═══════════════════════════════════════════════ */

.ck-table-wrap {
    overflow-x: auto;
    margin-top: 1.5rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.ck-projects-table {
    margin: 0;
    border: none;
    min-width: 1200px;
    table-layout: fixed;
}

.ck-projects-table th {
    background: #f1f5f9;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #475569;
    padding: 0.75rem 0.75rem;
    white-space: nowrap;
    border-bottom: 2px solid #e2e8f0;
}

.ck-projects-table td {
    font-size: 0.8rem;
    padding: 0.75rem 0.75rem;
    vertical-align: top;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    line-height: 1.5;
}

.ck-projects-table th:nth-child(1),
.ck-projects-table td:nth-child(1) { width: 110px; }

.ck-projects-table th:nth-child(2),
.ck-projects-table td:nth-child(2) { width: 90px; }

.ck-projects-table td,
.ck-projects-table th {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ck-projects-table tbody tr:hover {
    background: #f8fafc;
}

.ck-project-name-cell a {
    color: #0f172a;
    text-decoration: none;
    font-size: 0.85rem;
}

.ck-project-name-cell a:hover {
    color: #0d9488;
}

.ck-project-stats-inline {
    margin-top: 0.25rem;
}

/* Findings cell color coding */
.ck-finding-danger {
    background: #fef2f2;
    color: #991b1b;
}

.ck-finding-warning {
    background: #fffbeb;
    color: #92400e;
}

.ck-finding-success {
    background: #f0fdf4;
    color: #166534;
}

.ck-finding-info {
    background: #eff6ff;
    color: #1e40af;
}

.ck-finding-muted {
    color: #64748b;
}

/* Full row danger highlight */
.ck-row-danger td {
    background: #fef2f2;
}

/* ═══════════════════════════════════════════════════
   Entity Links (injected by ClawLinkManager)
   ═══════════════════════════════════════════════════ */

.ck-entity-link {
    color: #0d9488;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}

.ck-entity-link:hover {
    text-decoration-style: solid;
}
