/* ============================================
   Wiki System Styles
   Pup Cid's Little TikTok Helper
   ============================================ */

/* Wiki Container */
.wiki-container {
    display: flex;
    height: 100%;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
}

/* Wiki Sidebar */
.wiki-sidebar {
    width: 280px;
    background: var(--color-bg-secondary);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

/* Wiki Search */
.wiki-search-container {
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
    position: relative;
}

.wiki-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.wiki-search-input-wrapper i {
    position: absolute;
    left: 0.75rem;
    width: 16px;
    height: 16px;
    color: var(--color-text-muted);
    pointer-events: none;
}

.wiki-search-input {
    width: 100%;
    padding: 0.625rem 0.75rem 0.625rem 2.5rem;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text-primary);
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.wiki-search-input:focus {
    outline: none;
    border-color: var(--color-accent-primary);
    background: var(--color-bg-primary);
}

.wiki-search-input::placeholder {
    color: var(--color-text-muted);
}

/* Search Results */
.wiki-search-results {
    position: absolute;
    top: 100%;
    left: 1rem;
    right: 1rem;
    max-height: 400px;
    overflow-y: auto;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    margin-top: 0.5rem;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: none;
}

.wiki-search-result {
    display: block;
    padding: 0.75rem;
    border-bottom: 1px solid var(--color-border);
    text-decoration: none;
    color: var(--color-text-primary);
    transition: background 0.2s ease;
}

.wiki-search-result:last-child {
    border-bottom: none;
}

.wiki-search-result:hover {
    background: var(--color-bg-hover);
}

.wiki-search-result-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.wiki-search-result-excerpt {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    line-height: 1.4;
}

.wiki-search-result mark {
    background: rgba(59, 130, 246, 0.3);
    color: var(--color-accent-primary);
    padding: 0 2px;
    border-radius: 2px;
}

.wiki-search-no-results {
    padding: 2rem;
    text-align: center;
    color: var(--color-text-muted);
}

.wiki-search-no-results i {
    width: 32px;
    height: 32px;
    margin-bottom: 0.5rem;
}

/* Wiki Navigation */
.wiki-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.wiki-nav-section {
    margin-bottom: 0.5rem;
}

.wiki-nav-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    color: var(--color-text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.wiki-nav-section-header:hover {
    color: var(--color-text-primary);
    background: var(--color-bg-hover);
}

.wiki-nav-section-header i:first-child {
    width: 14px;
    height: 14px;
}

.wiki-nav-chevron {
    margin-left: auto;
    width: 14px;
    height: 14px;
    transition: transform 0.2s ease;
}

.wiki-nav-section.collapsed .wiki-nav-chevron {
    transform: rotate(-90deg);
}

.wiki-nav-section.collapsed .wiki-nav-items {
    display: none;
}

.wiki-nav-items {
    display: flex;
    flex-direction: column;
}

.wiki-nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 1rem 0.625rem 2.5rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.wiki-nav-item:hover {
    color: var(--color-text-primary);
    background: var(--color-bg-hover);
}

.wiki-nav-item.active {
    color: var(--color-accent-primary);
    background: rgba(59, 130, 246, 0.1);
    border-left-color: var(--color-accent-primary);
    font-weight: 500;
}

.wiki-nav-item i {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Wiki Content */
.wiki-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--color-bg-primary);
    display: flex;
    justify-content: center;
    min-width: 0;
}

.wiki-article {
    width: 100%;
    max-width: min(1400px, 95%);
    margin: 0 auto;
    padding: 2rem;
    box-sizing: border-box;
}

/* Responsive width adjustments for optimal reading */
@media (min-width: 1920px) {
    .wiki-article {
        max-width: min(1600px, 90%);
    }
}

@media (min-width: 2560px) {
    .wiki-article {
        max-width: min(1800px, 85%);
    }
}

@media (max-width: 1024px) {
    .wiki-article {
        max-width: 100%;
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .wiki-article {
        padding: 1rem;
    }
}

/* Loading State */
.wiki-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 4rem 2rem;
    color: var(--color-text-muted);
}

.wiki-loading i {
    width: 32px;
    height: 32px;
    animation: spin 1s linear infinite;
}

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

/* Error State */
.wiki-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 4rem 2rem;
    text-align: center;
}

.wiki-error i {
    width: 48px;
    height: 48px;
    color: var(--color-accent-danger);
}

.wiki-error h2 {
    color: var(--color-text-primary);
    margin: 0;
}

.wiki-error p {
    color: var(--color-text-secondary);
    margin: 0 0 1rem 0;
}

/* Article Content */
.wiki-article-content {
    background: var(--color-bg-card);
    border-radius: 12px;
    padding: 2.5rem;
    box-shadow: var(--shadow-md);
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 1024px) {
    .wiki-article-content {
        padding: 2rem;
    }
}

@media (max-width: 768px) {
    .wiki-article-content {
        padding: 1.5rem;
        border-radius: 8px;
    }
}

/* Breadcrumb */
.wiki-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    flex-wrap: wrap;
}

.wiki-breadcrumb a {
    color: var(--color-accent-primary);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.wiki-breadcrumb a:hover {
    opacity: 0.8;
}

.wiki-breadcrumb i {
    width: 12px;
    height: 12px;
}

/* Page Title */
.wiki-page-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 0 0 1.5rem 0;
    line-height: 1.2;
}

/* Table of Contents */
.wiki-toc {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.wiki-toc h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0 0 1rem 0;
}

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

.wiki-toc-nav ul ul {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
}

.wiki-toc-nav li {
    margin-bottom: 0.5rem;
}

.wiki-toc-nav a {
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s ease;
    display: inline-block;
}

.wiki-toc-nav a:hover {
    color: var(--color-accent-primary);
}

/* Markdown Content */
.wiki-markdown-content {
    color: var(--color-text-primary);
    line-height: 1.7;
}

.wiki-markdown-content h1,
.wiki-markdown-content h2,
.wiki-markdown-content h3,
.wiki-markdown-content h4,
.wiki-markdown-content h5,
.wiki-markdown-content h6 {
    color: var(--color-text-primary);
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 1rem;
    line-height: 1.3;
}

.wiki-markdown-content h1 {
    font-size: 1.875rem;
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 0.5rem;
}

.wiki-markdown-content h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.5rem;
}

.wiki-markdown-content h3 {
    font-size: 1.25rem;
}

.wiki-markdown-content h4 {
    font-size: 1.125rem;
}

.wiki-markdown-content p {
    margin-bottom: 1rem;
}

.wiki-markdown-content ul,
.wiki-markdown-content ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.wiki-markdown-content li {
    margin-bottom: 0.5rem;
}

.wiki-markdown-content a {
    color: var(--color-accent-primary);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.wiki-markdown-content a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.wiki-markdown-content code {
    background: var(--color-bg-tertiary);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.875em;
    font-family: 'Courier New', monospace;
    color: var(--color-accent-secondary);
}

.wiki-markdown-content pre {
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.wiki-markdown-content pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    color: var(--color-text-primary);
}

.wiki-markdown-content blockquote {
    border-left: 4px solid var(--color-accent-primary);
    margin: 1rem 0;
    padding-left: 1rem;
    color: var(--color-text-secondary);
    font-style: italic;
}

.wiki-markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    background: var(--color-bg-secondary);
    border-radius: 8px;
    overflow: hidden;
}

.wiki-markdown-content th,
.wiki-markdown-content td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.wiki-markdown-content th {
    background: var(--color-bg-tertiary);
    font-weight: 600;
    color: var(--color-text-primary);
}

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

.wiki-markdown-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
    display: block;
    box-shadow: var(--shadow-md);
    cursor: pointer;
}

.wiki-markdown-content hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 2rem 0;
}

/* Article Footer */
.wiki-article-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.wiki-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.wiki-meta i {
    width: 14px;
    height: 14px;
}

/* Image Modal */
.wiki-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wiki-image-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
}

.wiki-image-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.wiki-image-modal-close {
    position: absolute;
    top: -3rem;
    right: 0;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.wiki-image-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.wiki-image-modal-close i {
    width: 24px;
    height: 24px;
}

.wiki-image-modal-content img {
    max-width: 100%;
    max-height: calc(90vh - 4rem);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.wiki-image-modal-caption {
    color: white;
    text-align: center;
    font-size: 0.875rem;
}
