/* VeriDoc Component Styles */

/* File Tree */
.file-tree {
    padding: var(--spacing-sm) 0;
}

.tree-item {
    height: auto;
    min-height: 32px;
    padding: var(--spacing-xs) var(--spacing-sm);
    display: flex;
    align-items: center;
    cursor: pointer;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    border-radius: 4px;
    margin-bottom: var(--spacing-xs);
    transition: all var(--transition-fast);
    user-select: none;
}

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

.tree-item.selected {
    background: var(--accent-blue);
    color: var(--text-accent);
}

.tree-item.directory {
    font-weight: 500;
}

.tree-icon {
    width: 16px;
    height: 16px;
    margin-right: var(--spacing-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.tree-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Remove tree-expand and tree-children styles - using navigation-only approach */

/* Force proper code formatting - highest specificity */
.content-code .code-content .code-line .line-content {
    white-space: pre !important;
    text-align: left !important;
    word-break: normal !important;
    word-wrap: normal !important;
    overflow-wrap: normal !important;
    text-justify: none !important;
    font-family: 'Consolas', 'Liberation Mono', 'Menlo', monospace !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
}

.content-code .code-content .code-line {
    line-height: 1.4 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    gap: 0 !important;
}

.content-code .code-content {
    font-family: 'Consolas', 'Liberation Mono', 'Menlo', monospace !important;
    text-align: left !important;
    margin: 0 !important;
    padding: 0 !important;
}

.content-code pre.code-content {
    margin: 0 !important;
    padding: var(--spacing-sm) var(--spacing-md) !important;
}

/* Table-based code layout */
.code-table {
    width: 100%;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    font-family: 'Consolas', 'Liberation Mono', 'Menlo', monospace !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
}

.code-table .code-line {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    line-height: 1.4 !important;
}

.code-table .line-number {
    color: var(--text-secondary);
    text-align: right;
    user-select: none;
    width: 50px;
    padding: 0 var(--spacing-sm) 0 0 !important;
    margin: 0 !important;
    border-right: 1px solid var(--border);
    font-family: 'Consolas', 'Liberation Mono', 'Menlo', monospace !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    vertical-align: top;
}

.code-table .line-content {
    padding: 0 0 0 var(--spacing-sm) !important;
    margin: 0 !important;
    white-space: pre !important;
    text-align: left !important;
    word-break: normal !important;
    word-wrap: normal !important;
    overflow-wrap: normal !important;
    text-justify: none !important;
    vertical-align: top;
}

.code-table .line-content code {
    background: none !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    font-family: inherit !important;
    font-size: inherit !important;
    line-height: inherit !important;
    white-space: pre !important;
    text-align: left !important;
}

/* Content Display */
.content-markdown {
    width: 100%;
    max-width: none;
    margin: 0;
    line-height: 1.6;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.content-code {
    width: 100%;
    max-width: none;
    margin: 0;
    background: var(--bg-primary);
    border-radius: 6px;
    overflow: hidden;
    font-family: 'Consolas', 'Liberation Mono', 'Menlo', 'Courier', monospace !important;
    text-align: left !important;
    white-space: pre !important;
    word-break: normal !important;
    word-wrap: normal !important;
    overflow-wrap: normal !important;
    text-justify: none !important;
}

.content-markdown h1 {
    color: var(--text-accent);
    font-size: var(--font-size-3xl);
    margin-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border);
    padding-bottom: var(--spacing-sm);
}

.content-markdown h2 {
    color: var(--text-accent);
    font-size: var(--font-size-2xl);
    margin-top: var(--spacing-lg);
    margin-bottom: var(--spacing-sm);
}

.content-markdown h3 {
    color: var(--text-accent);
    font-size: var(--font-size-xl);
    margin-top: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
}

.content-markdown h4,
.content-markdown h5,
.content-markdown h6 {
    color: var(--text-accent);
    margin-top: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
}

.content-markdown p {
    margin-bottom: var(--spacing-md);
}

.content-markdown ul,
.content-markdown ol {
    margin-bottom: var(--spacing-md);
    padding-left: var(--spacing-lg);
}

.content-markdown li {
    margin-bottom: var(--spacing-xs);
}

.content-markdown blockquote {
    border-left: 4px solid var(--accent-blue);
    margin: var(--spacing-md) 0;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-tertiary);
    font-style: italic;
}

.content-markdown code {
    background: var(--bg-tertiary);
    padding: 2px 4px;
    border-radius: 3px;
    font-size: var(--font-size-sm);
}

.content-markdown pre {
    background: var(--bg-tertiary);
    padding: var(--spacing-md);
    border-radius: 6px;
    overflow-x: auto;
    margin: var(--spacing-md) 0;
    border: 1px solid var(--border);
}

.content-markdown pre code {
    background: none;
    padding: 0;
}

.content-markdown table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--spacing-md) 0;
    font-size: var(--font-size-sm);
}

.content-markdown th,
.content-markdown td {
    border: 1px solid var(--border);
    padding: var(--spacing-sm);
    text-align: left;
}

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

.content-markdown a {
    color: var(--accent-blue);
    text-decoration: none;
}

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

.content-markdown img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: var(--spacing-md) 0;
}

.content-markdown hr {
    border: none;
    height: 1px;
    background: var(--border);
    margin: var(--spacing-lg) 0;
}

/* Code with line numbers */
.content-code {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: auto;
    font-family: 'Fira Code', monospace;
    font-size: var(--font-size-sm);
}

.code-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: var(--spacing-sm) var(--spacing-md);
    margin: 0;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.code-content {
    padding: 0 !important;
    margin: 0 !important;
    overflow: auto;
    font-family: 'Consolas', 'Liberation Mono', 'Menlo', 'Courier', monospace;
    font-size: 14px;
    line-height: 1.4;
    background: var(--bg-primary);
}

.code-line {
    display: flex;
    min-height: 20px;
    line-height: 1.4;
    align-items: flex-start;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
}

.line-number {
    color: var(--text-secondary);
    margin-right: var(--spacing-md);
    text-align: right;
    user-select: none;
    min-width: 40px;
    padding-right: var(--spacing-sm);
    border-right: 1px solid var(--border);
    font-family: 'Consolas', 'Liberation Mono', 'Menlo', 'Courier', monospace;
    font-size: 14px;
    line-height: 1.4;
}

.line-content {
    flex: 1;
    padding-left: var(--spacing-md);
    white-space: pre !important;
    font-family: 'Consolas', 'Liberation Mono', 'Menlo', 'Courier', monospace !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    overflow-x: auto;
    text-align: left !important;
    word-break: normal !important;
    word-wrap: normal !important;
    overflow-wrap: normal !important;
    text-justify: none !important;
}

/* Find Dialog */
.find-dialog {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
    min-width: 300px;
}

.find-content {
    padding: var(--spacing-sm);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.find-dialog input {
    flex: 1;
    height: 28px;
}

.find-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.find-controls button {
    width: 24px;
    height: 24px;
    padding: 0;
    font-size: var(--font-size-xs);
}

.find-count {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    min-width: 40px;
    text-align: center;
}

/* Search highlighting */
.search-highlight {
    background: var(--accent-yellow);
    color: var(--bg-primary);
    padding: 1px 2px;
    border-radius: 2px;
}

.search-highlight.current {
    background: var(--accent-blue);
    color: var(--text-accent);
}

/* Table of Contents */
.toc-panel {
    position: absolute;
    top: 36px; /* Start below the panel header */
    right: 0;
    width: 280px;
    height: calc(100% - 36px); /* Subtract header height */
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    border-radius: 8px 0 0 0;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    z-index: 50;
    transform: translateX(100%);
    transition: transform var(--transition-base);
}

.toc-panel.open {
    transform: translateX(0);
}

.toc-content {
    height: 100%;
    overflow-y: auto;
    padding: var(--spacing-md);
}

.toc-item {
    display: block;
    padding: var(--spacing-xs) var(--spacing-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    border-radius: 4px;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.toc-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-accent);
}

.toc-item.level-1 {
    font-weight: 600;
    margin-top: var(--spacing-sm);
}

.toc-item.level-2 {
    margin-left: var(--spacing-md);
}

.toc-item.level-3 {
    margin-left: var(--spacing-lg);
    font-size: var(--font-size-xs);
}

.toc-item.level-4,
.toc-item.level-5,
.toc-item.level-6 {
    margin-left: var(--spacing-xl);
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

/* Error states */
.error-display {
    padding: var(--spacing-lg);
    text-align: center;
    color: var(--text-secondary);
}

.error-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-md);
    color: var(--accent-red);
}

.error-title {
    font-size: var(--font-size-xl);
    margin-bottom: var(--spacing-sm);
    color: var(--text-accent);
}

.error-message {
    margin-bottom: var(--spacing-md);
}

.error-actions {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
}

.error-button {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--accent-blue);
    color: var(--text-accent);
    border-radius: 4px;
    text-decoration: none;
    font-size: var(--font-size-sm);
}

.error-button:hover {
    background: #0056b3;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

@keyframes slideInDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

.fade-in {
    animation: fadeIn var(--transition-base);
}

.slide-in-right {
    animation: slideInRight var(--transition-base);
}

.slide-in-down {
    animation: slideInDown var(--transition-base);
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .find-dialog {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: 400px;
    }
    
    .toc-panel {
        width: 100%;
    }
    
    .content-markdown {
        max-width: none;
    }
    
    .content-display {
        padding: var(--spacing-md);
    }
}