* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f3f3f3;
    overflow: hidden;
    min-height: 100vh;
}

.explorer-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 8px 12px;
    min-height: 48px;
    gap: 8px;
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 240px;
    min-width: 220px;
}

.toolbar-right {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: 1 1 260px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.search-container {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-right: 8px;
    flex: 1 1 220px;
    min-width: 200px;
}

.search-input {
    padding: 6px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 3px;
    font-size: 13px;
    width: 100%;
    outline: none;
}

.search-input:focus {
    border-color: #0078d4;
}

.search-input::placeholder {
    color: #999;
}

.toolbar-btn {
    background: transparent;
    border: 1px solid transparent;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 3px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: #f0f0f0;
    border-color: #d0d0d0;
}

.toolbar-btn.active {
    background: #e6f2ff;
    border-color: #0078d4;
}

.toolbar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 3px;
    flex: 1 1 240px;
    min-width: 180px;
    max-width: 600px;
    overflow: hidden;
    white-space: nowrap;
}

.breadcrumb-item {
    color: #0078d4;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 2px;
}

.breadcrumb-item:hover {
    background: #e6f2ff;
}

.breadcrumb-item:after {
    content: '›';
    margin: 0 4px;
    color: #666;
}

.breadcrumb-item:last-child:after {
    content: '';
}

/* Main Container */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: #f9f9f9;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 12px 16px;
    font-weight: 600;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
}

.sidebar-section {
    border-bottom: 1px solid #e0e0e0;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar-section-title {
    user-select: none;
}

.sidebar-section-title:hover {
    background: #f0f0f0;
}

.sidebar-tree {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.tree-item {
    padding: 6px 16px 6px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    user-select: none;
}

.tree-item:hover {
    background: #e6f2ff;
}

.tree-item.selected {
    background: #cce8ff;
    font-weight: 600;
}

.tree-item.folder {
    padding-left: 8px;
}

.tree-item.subfolder {
    font-size: 13px;
}

.tree-item-child {
    padding-left: 24px;
}

.tree-expand {
    width: 12px;
    color: #666;
    font-size: 10px;
    flex-shrink: 0;
    display: inline-block;
    text-align: center;
}

.tree-icon {
    width: 0;
    height: 0;
    flex-shrink: 0;
    visibility: hidden;
}

/* Splitter */
.splitter {
    width: 4px;
    background: #e0e0e0;
    cursor: col-resize;
}

.splitter:hover {
    background: #0078d4;
}

/* Content Area */
.content-area {
    flex: 1;
    background: #fff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* File List View */
.file-list-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.folder-note {
    background: #fff3cd;
    border: 1px solid #ffc107;
    padding: 12px 16px;
    margin: 0;
    font-size: 13px;
    color: #856404;
    line-height: 1.5;
}

.file-list-header {
    display: flex;
    background: #f9f9f9;
    border-bottom: 1px solid #e0e0e0;
    padding: 8px 12px;
    font-weight: 600;
    font-size: 13px;
    color: #666;
}

.file-list-col {
    padding: 0 8px;
}

.file-list-name {
    flex: 1;
}

.file-list-action {
    width: 140px;
    text-align: center;
}

.file-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.file-item-wrapper {
    border-bottom: 1px solid #f0f0f0;
}

.file-item {
    display: flex;
    padding: 8px 12px;
    cursor: pointer;
    align-items: center;
}

.file-item:hover {
    background: #f5f5f5;
}

.file-item.selected {
    background: #e6f2ff;
}

.file-summary {
    padding: 12px 16px;
    background: #f0f8ff;
    border-top: 1px solid #b8daff;
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
}

.file-item-name {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
    overflow: hidden;
}

.file-item-name span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.file-item-action {
    width: 140px;
    padding: 0 8px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.summary-btn {
    background: #0078d4;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 3px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.summary-btn:hover {
    background: #106ebe;
}

.summary-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Thumbnail View */
.thumbnail-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.thumbnail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.thumbnail-item:hover {
    background: #f5f5f5;
    border-color: #d0d0d0;
}

.thumbnail-item.selected {
    background: #e6f2ff;
    border-color: #0078d4;
}

.thumbnail-preview {
    width: 140px;
    height: 180px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    overflow: hidden;
}

.thumbnail-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.thumbnail-preview-icon {
    font-size: 48px;
    color: #999;
}

.thumbnail-name {
    font-size: 13px;
    text-align: center;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Empty State */
.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    font-size: 14px;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #666;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

/* PDF Modal */
.pdf-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-modal-content {
    background: #2b2b2b;
    width: 95%;
    height: 95%;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    overflow: hidden;
}

.pdf-modal-header {
    background: #1e1e1e;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #444;
}

.document-summary {
    padding: 16px;
    background: #f0f8ff;
    border-bottom: 1px solid #b8daff;
    margin: 0;
}

.document-summary .summary-title {
    font-weight: bold;
    color: #004085;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.document-summary .summary-content {
    color: #333;
    line-height: 1.6;
    white-space: pre-wrap;
}

.document-summary .summary-loading {
    color: #666;
    font-style: italic;
}

.document-summary .summary-error {
    color: #dc3545;
}

.pdf-title {
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}

.pdf-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pdf-btn {
    background: #3c3c3c;
    color: #fff;
    border: 1px solid #555;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 3px;
    font-size: 13px;
    transition: all 0.2s;
}

.pdf-btn:hover {
    background: #4c4c4c;
}

.pdf-btn.close-btn {
    background: #c42b1c;
    border-color: #c42b1c;
}

.pdf-btn.close-btn:hover {
    background: #e81123;
}

.page-info {
    color: #ccc;
    font-size: 13px;
    padding: 0 8px;
}

.zoom-level {
    color: #ccc;
    font-size: 13px;
    min-width: 50px;
    text-align: center;
}

.divider {
    color: #666;
    padding: 0 4px;
}

.pdf-modal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    background: #2b2b2b;
}

.pdf-canvas-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px;
    overflow-y: auto;
}

.pdf-page {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    display: block;
}

/* Progress Modal */
.progress-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-modal-content {
    background: #fff;
    width: 500px;
    max-width: 90%;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.progress-header {
    background: #0078d4;
    color: #fff;
    padding: 16px 20px;
}

.progress-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.progress-body {
    padding: 24px 20px;
}

.progress-bar-container {
    width: 100%;
    height: 24px;
    background: #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #0078d4, #00bcf2);
    border-radius: 12px;
    transition: width 0.3s ease;
    width: 0%;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.progress-text {
    font-size: 14px;
    color: #333;
    margin-bottom: 8px;
    font-weight: 500;
}

.progress-stats {
    font-size: 13px;
    color: #666;
}

/* Status Bar */
.status-bar {
    background: #f9f9f9;
    border-top: 1px solid #e0e0e0;
    padding: 4px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #666;
    height: 28px;
}

.status-text {
    flex: 1;
}

.file-count {
    padding: 0 8px;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: #f0f0f0;
}

::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* PDF Icons */
.file-icon::before {
    content: '📄';
}

.tree-icon::before {
    content: '';
}

.file-item.changed-file:hover {
    background: #ffe69c;
}

.file-item.original-file {
    opacity: 0.7;
}

/* Search Modal */
.search-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

/* Responsive tweaks */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }
    .file-list-action {
        width: 120px;
    }
    .thumbnail-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

@media (max-width: 768px) {
    body {
        overflow: auto;
    }
    .toolbar {
        justify-content: flex-start;
    }
    .toolbar-right {
        justify-content: flex-start;
    }
    .breadcrumb {
        max-width: 100%;
    }
    .main-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        max-height: 220px;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
    .splitter {
        display: none;
    }
    .content-area {
        height: calc(100vh - 220px - 70px);
    }
    .file-list-header {
        font-size: 12px;
    }
    .file-list-action,
    .file-item-action {
        width: 100px;
    }
}

@media (max-width: 540px) {
    .toolbar {
        padding: 6px 10px;
    }
    .search-container {
        flex: 1 1 100%;
        margin-right: 0;
    }
    .search-input {
        width: 100%;
    }
    .toolbar-btn {
        padding: 6px 8px;
    }
    .breadcrumb {
        display: none;
    }
    .sidebar {
        max-height: 180px;
    }
    .file-list-col.file-list-action {
        width: 80px;
    }
    .file-item-action {
        width: 80px;
    }
    .summary-btn {
        padding: 4px 8px;
        font-size: 11px;
    }
    .file-item-name {
        padding-right: 0;
    }
}

.search-modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.search-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f9f9f9;
    border-radius: 8px 8px 0 0;
}

.search-modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.close-search-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    padding: 4px 8px;
    line-height: 1;
}

.close-search-btn:hover {
    color: #333;
}

.search-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.search-results-header {
    font-size: 14px;
    color: #666;
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 8px;
}

.search-result-item {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 12px;
    transition: box-shadow 0.2s;
}

.search-result-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.search-result-filename {
    font-weight: 600;
    font-size: 14px;
    color: #0066cc;
    cursor: pointer;
    margin-bottom: 6px;
}

.search-result-filename:hover {
    text-decoration: underline;
}

.search-result-matches {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
}

.search-result-previews {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.search-result-preview {
    background: white;
    border-left: 3px solid #0078d4;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.search-result-preview:hover {
    background: #f5f5f5;
}

.search-result-preview .page-number {
    font-weight: 600;
    color: #0078d4;
    margin-right: 8px;
}

.search-result-preview .context {
    color: #333;
    line-height: 1.5;
}

.search-result-preview mark {
    background: #ffeb3b;
    padding: 2px 4px;
    border-radius: 2px;
    font-weight: 600;
}

.search-results .loading,
.search-results .error,
.search-results .empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.search-results .error {
    color: #d32f2f;
}
