/* 📚 Codex Panel Styles */

.panel-codex {
    /* Panel layout handled by unified system */
}

.panel-codex .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.panel-codex .panel-body {
    padding: 0;
    display: flex;
    height: calc(100% - 60px);
}

/* Codex Sidebar */
.codex-sidebar {
    width: 250px;
    background: rgba(0, 0, 0, 0.3);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    overflow-y: auto;
    flex-shrink: 0;
}

.codex-nav {
    padding: 0.5rem;
}

.codex-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 0.25rem;
    width: 100%;
    text-align: left;
}

.codex-nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.codex-nav-item.active {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.4);
    color: #a78bfa;
}

.codex-nav-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* Codex Content */
.codex-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

/* Doc Viewer Layout */
.codex-doc-viewer {
    max-width: 900px;
    margin: 0 auto;
}

.codex-doc-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 2rem;
}

.codex-back-btn {
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.4);
    color: #a78bfa;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.codex-back-btn:hover {
    background: rgba(139, 92, 246, 0.3);
    border-color: rgba(139, 92, 246, 0.6);
}

.codex-breadcrumb {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
}

.codex-breadcrumb::before {
    content: '/ ';
    margin-right: 0.25rem;
}

/* Markdown Content */
.codex-markdown-content {
    padding: 1rem 0;
    color: rgba(255, 255, 255, 0.85);
}

.codex-markdown-content h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: #fff;
    border-bottom: 3px solid rgba(139, 92, 246, 0.3);
    padding-bottom: 0.75rem;
    margin-top: 0;
}

.codex-markdown-content h2 {
    font-size: 1.75rem;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    color: #a78bfa;
}

.codex-markdown-content h3 {
    font-size: 1.35rem;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: rgba(255, 255, 255, 0.95);
}

.codex-markdown-content p {
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.7;
    margin-bottom: 1.25rem;
}

.codex-markdown-content hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 2.5rem 0;
}

.codex-markdown-content ul,
.codex-markdown-content ol {
    margin: 1.25rem 0;
    padding-left: 2rem;
}

.codex-markdown-content li {
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 0.75rem;
    line-height: 1.7;
}

.codex-markdown-content blockquote {
    border-left: 4px solid rgba(139, 92, 246, 0.5);
    padding-left: 1.25rem;
    margin: 1.5rem 0;
    color: rgba(255, 255, 255, 0.75);
    font-style: italic;
}

/* Code Styling */
.codex-markdown-content code {
    background: rgba(139, 92, 246, 0.15);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.codex-markdown-content pre {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-left: 4px solid rgba(139, 92, 246, 0.5);
    padding: 1.25rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.codex-markdown-content pre code {
    background: none;
    padding: 0;
    border: none;
    color: rgba(255, 255, 255, 0.9);
}

/* Table Styling */
.codex-markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.codex-markdown-content th {
    background: rgba(139, 92, 246, 0.2);
    color: #c4b5fd;
    padding: 0.85rem 1rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid rgba(139, 92, 246, 0.4);
    font-size: 0.95rem;
}

.codex-markdown-content td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.85);
}

.codex-markdown-content tr:last-child td {
    border-bottom: none;
}

.codex-markdown-content tbody tr:hover {
    background: rgba(139, 92, 246, 0.05);
}

/* Doc Navigation (Prev/Next) */
.codex-doc-navigation {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.codex-nav-doc {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
}

.codex-nav-doc:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.4);
    color: #a78bfa;
}

.codex-nav-prev {
    justify-content: flex-start;
}

.codex-nav-next {
    justify-content: flex-end;
}

.codex-nav-arrow {
    font-size: 1.25rem;
    color: rgba(139, 92, 246, 0.6);
}

.codex-nav-label {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Doc Index */
.codex-doc-index {
    max-width: 900px;
    margin: 0 auto;
}

.codex-doc-welcome {
    text-align: center;
    padding: 2rem 1rem;
    margin-bottom: 2rem;
}

.codex-doc-welcome h2 {
    font-size: 2rem;
    color: #fff;
    margin-bottom: 0.75rem;
}

.codex-doc-welcome p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.1rem;
}

.codex-doc-categories {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.codex-doc-category {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.codex-doc-category:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.4);
    transform: translateY(-2px);
}

.codex-doc-category-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.codex-doc-category-icon {
    font-size: 1.5rem;
}

.codex-doc-category-header h3 {
    flex: 1;
    font-size: 1.25rem;
    color: #fff;
    margin: 0;
}

.codex-doc-count {
    background: rgba(139, 92, 246, 0.3);
    color: #c4b5fd;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.codex-doc-category-desc {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    margin: 0;
}

/* Category View */
.codex-category-view {
    max-width: 900px;
    margin: 0 auto;
}

.codex-category-header {
    margin-bottom: 2rem;
}

.codex-category-header h2 {
    font-size: 2rem;
    color: #fff;
    margin: 1rem 0;
}

.codex-doc-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.codex-doc-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.85);
    transition: all 0.2s;
}

.codex-doc-link:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.4);
    color: #a78bfa;
}

.codex-doc-title {
    font-weight: 500;
}

.codex-doc-arrow {
    color: rgba(139, 92, 246, 0.6);
    font-size: 1.25rem;
}

/* Loading State */
.codex-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: rgba(255, 255, 255, 0.5);
}

.codex-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #a78bfa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Tab Bar */
.codex-tab-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.codex-tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: rgba(255, 255, 255, 0.6);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.codex-tab-btn:hover {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.05);
}

.codex-tab-btn.active {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.4);
    color: #a78bfa;
}

.codex-body {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.codex-tab {
    display: none;
    height: 100%;
    overflow-y: auto;
}

.codex-tab.active {
    display: block;
}

/* Panel Structure */
.codex-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.codex-header {
    flex-shrink: 0;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .codex-doc-categories {
        grid-template-columns: 1fr;
    }

    .codex-doc-navigation {
        grid-template-columns: 1fr;
    }

    .codex-markdown-content {
        padding: 0.5rem;
    }

    .codex-markdown-content h1 {
        font-size: 1.75rem;
    }

    .codex-markdown-content h2 {
        font-size: 1.35rem;
    }

    .codex-markdown-content table {
        font-size: 0.85rem;
    }

    .codex-markdown-content th,
    .codex-markdown-content td {
        padding: 0.5rem 0.75rem;
    }
}
