/* Minimal custom styling - let XP.css handle the rest */

:root {
    --xp-silver: #ece9d8;
    --xp-border: #666666;
    --gradient-silver: linear-gradient(180deg, #ffffff 0%, #ece9d8 100%);
    --xp-text: #000000;
    --font-size: 12px;
    --document-font-size: 14px;
}

body {
    background: var(--xp-silver);
    font-family: 'Tahoma', sans-serif;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

button {
    font-size: var(--font-size);
    cursor: pointer;
}

.window {
    width: 60vw;
    margin: 2% auto;
    overflow: visible;
}

/* Responsive window widths */
@media (max-width: 1225px) {
    .window {
        width: 80vw;
    }
}

@media (max-width: 400px) {
    .window {
        width: 90vw;
    }
}

/* Toolbar */
.toolbar {
    background: var(--xp-silver);
    border-bottom: 1px solid #808080;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Toolbar Navigation Buttons - Override xp.css with more specific selectors */
.toolbar .toolbar-button {
    /* Keep xp.css button frame but adjust sizing */
    min-width: auto !important;
    height: 38px !important;
    padding: 4px 8px !important;
    margin-right: 2px;
    font-size: var(--font-size);
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    border: none;
    background-color: transparent !important;
    cursor: pointer;
}

/* Remove ugly orange hover effect from xp.css */
.toolbar .toolbar-button:hover,
.toolbar .toolbar-button:focus {
    background-color: transparent !important;
    box-shadow: none !important;
}

/* Back Button - keep PNG icon, let xp.css handle button frame */
.toolbar .toolbar-button[title="Back"] {
    background-image: url('../images/577_back-0.png') !important;
    background-repeat: no-repeat !important;
    background-position: 4px center !important;
    background-size: 24px 24px !important;
    padding-left: 30px !important;
}

.toolbar .toolbar-button[title="Back"]::after {
    content: 'Back';
}

/* Hover state */
.toolbar .toolbar-button[title="Back"]:hover:not(:disabled) {
    background-image: url('../images/578_back-0.png') !important;
}

/* Active state */
.toolbar .toolbar-button[title="Back"]:active:not(:disabled) {
    background-image: url('../images/578_back-0.png') !important;
}

/* Forward Button - icon only, no text */
.toolbar .toolbar-button[title="Forward"] {
    background-image: url('../images/577_back-1.png') !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 24px 24px !important;
    width: 34px !important;
    padding: 2px !important;
}

.toolbar .toolbar-button[title="Forward"]:hover:not(:disabled) {
    background-image: url('../images/578_back-1.png') !important;
}

.toolbar .toolbar-button[title="Forward"]:active:not(:disabled) {
    background-image: url('../images/578_back-1.png') !important;
}

/* Disabled states */
.toolbar .toolbar-button[title="Back"]:disabled {
    background-image: url('../images/579_back-0.png') !important;
    cursor: not-allowed;
}

.toolbar .toolbar-button[title="Forward"]:disabled {
    background-image: url('../images/579_back-1.png') !important;
    cursor: not-allowed;
}

/* Paper header section - layout only */
.paper-header {
    padding: 5% 0 0 0;
    text-align: center;
}

.paper-title {
    font-size: 42px;
    font-weight: 700;
    margin: 0 auto 30px;
    max-width: 1000px;
    line-height: 1.3;
}

.paper-authors {
    font-size: 20px;
    margin-bottom: 15px;
    line-height: 1.6;
}

.paper-institutions {
    font-size: 18px;
    color: #6b7280;
    margin-bottom: 20px;
    line-height: 1.6;
}

/* Button container layout */
.paper-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Icons inside buttons should align with text */
.paper-buttons button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Button icon sizing */
.paper-buttons .btn-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

/* Test sections below */
.test-section {
    background: white;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #999;
}

.test-section h2 {
    margin-top: 0;
    border-bottom: 2px solid #0054E3;
    padding-bottom: 10px;
}

.folder-icon {
    width: 16px;
    height: 16px;
    background: url('../images/windows_xp_folder.png') no-repeat center center;
    background-size: contain;
}

/* Title bar text alignment - keep icon and text together on left */
.title-bar-text {
    display: flex !important;
    align-items: center;
    gap: 6px;
    justify-content: flex-start !important;
}

.window-body {
    margin: 0px 3px;
}

/* Address Bar */
.address-bar {
    background: var(--xp-silver);
    border-top: 1px solid #ffffff;
    border-bottom: 1px solid #808080;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.address-label {
    font-weight: bold;
    font-size: var(--font-size);
}

.address-input {
    flex: 1;
    height: 20px;
    border: 2px inset var(--xp-silver);
    padding: 2px 4px;
    font-family: 'Tahoma', sans-serif;
    font-size: var(--font-size);
    background: white;
}

.go-button {
    padding: 2px 8px;
    border: 1px outset var(--xp-silver);
    background: var(--xp-silver);
    cursor: pointer;
    font-family: 'Tahoma', sans-serif;
    font-size: var(--font-size);
}

.go-button:hover {
    background: #f0f0f0;
}

.go-button:active {
    border-style: inset;
}

/* File List */
.file-list-container {
    --file-table-columns: minmax(120px, 1.5fr) minmax(120px, 1.5fr) minmax(110px, 1.5fr) minmax(100px, 1fr) minmax(120px, 1.5fr);
    --file-table-min-width: 600px;
    flex: 1;
    background: #ffffff;
    overflow: auto;
}

.file-list-header {
    background: var(--xp-silver);
    border-bottom: 1px solid var(--xp-border);
    border-top: 1px solid #ffffff;
    display: grid;
    grid-template-columns: var(--file-table-columns);
    min-width: var(--file-table-min-width);
    box-sizing: border-box;
    padding: 4px;
    font-weight: bold;
    font-size: var(--font-size);
}

.header-cell {
    padding: 4px;
    border-right: 1px solid var(--xp-border);
    cursor: pointer;
    line-height: 1.2;
    display: flex;
    align-items: center;
}

.header-cell:last-child {
    border-right: none;
}

/* Sortable header styles */
.header-cell[data-sort] {
    user-select: none;
}

.header-cell[data-sort]:hover {
    background: #d4d1c8;
}

.header-cell[data-sort]:active {
    background: #c0bdb4;
}


.file-list {
    background: #ffffff;
    min-width: var(--file-table-min-width);
}

.file-item {
    display: grid;
    grid-template-columns: var(--file-table-columns);
    box-sizing: border-box;
    padding: 2px 4px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    align-items: center;
}

.file-item:last-child {
    border-bottom: none;
}

.file-item:hover {
    background: #316ac5;
    color: #ffffff;
}

.file-item:active {
    background: #003875;
}

.file-name {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
}

.file-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.folder-icon-small {
    background: url('../images/windows_xp_folder.png') no-repeat center center;
    background-size: contain;
}

.file-size, .file-company-size, .file-type, .file-date {
    padding: 4px 8px;
    font-size: var(--font-size);
}

#doc-viewer-panels {
    display: flex;
}

/* Document viewer page - center window */
#main-content:has(#doc-viewer-panels) {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

body:has(#doc-viewer-panels) {
    overflow: hidden;
}

#main-content:has(#doc-viewer-panels) .window {
    width: 90vw !important;
    height: 89vh !important;
    margin: 0 !important;
    max-width: 94vw !important;
    max-height: 93vh !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
}

#main-content:has(#doc-viewer-panels) .window-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

#doc-viewer-panels {
    flex: 1;
    display: flex !important;
    flex-direction: row !important;
    background: #ffffff;
    min-height: 0;
    overflow: hidden;
}

#doc-left-panel {
    width: 26%;
    flex-shrink: 0;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#doc-left-panel #left-panel-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#doc-left-panel .tree-view {
    flex: 1;
    overflow-y: auto;
}

#doc-middle-panel {
    flex: 1;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

#doc-middle-panel #document-viewer {
    flex: 1;
    overflow-y: auto;
    border-right: 1px solid var(--xp-border);
}

#doc-right-panel {
    width: 26%;
    flex-shrink: 0;
    background-color: #ffffff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#doc-right-panel #properties-panel {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.doc-panel-header {
    background: var(--xp-silver);
    border-bottom: 1px solid var(--xp-border);
    border-top: 1px solid #ffffff;
    padding: 8px;
    font-weight: bold;
    font-size: var(--font-size);
    flex-shrink: 0;
}

/* Add borders between panel headers */
#doc-left-panel .doc-panel-header {
    border-right: 1px solid var(--xp-border);
}

#doc-middle-panel .doc-panel-header {
    border-right: 1px solid var(--xp-border);
}

/* Rightmost panel header has no right border */
#doc-right-panel .doc-panel-header {
    border-right: none;
}

.doc-document-content {
    font-size: var(--document-font-size);
    line-height: 1.7;
    white-space: pre-wrap;
    padding: 8px;
}

.doc-document-content .document-logo {
    display: block;
    width: auto;
    height: auto;
    max-width: 270px;
    max-height: 72px;
    object-fit: contain;
    margin: 8px 0;
}

.doc-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c757d;
    font-style: italic;
    padding: 2rem;
}

/* Highlighting styles */
.highlight-source {
    background-color: rgba(33, 150, 243, 0.3);
    padding: 1px 2px;
    border-radius: 2px;
}

.highlight-target {
    background-color: rgba(76, 175, 80, 0.3);
    padding: 1px 2px;
    border-radius: 2px;
}

.highlight-nugget {
    background-color: rgba(255, 235, 59, 0.4);
    padding: 1px 2px;
    border-radius: 2px;
}

/* Properties panel */
.doc-property {
    padding: 8px;
    border-bottom: 1px solid var(--xp-border);
    color: var(--xp-text);
}

.doc-property-label {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.doc-property-value {
    word-break: break-word;
}

.doc-relationship-evidence {
    padding: 8px;
    border-bottom: 1px solid var(--xp-border);
}

.doc-evidence-item {
    background-color: #dfdfdf;
    padding: 8px;
    margin-top: 8px;
    border-left: 3px solid #000000;

}

.doc-evidence-item div {
    font-size: var(--font-size);
    margin-bottom: 0.5rem;
    word-wrap: break-word;
    word-break: break-all;
    overflow-wrap: anywhere;
    white-space: normal;
}

.doc-evidence-nugget {
    font-style: italic;
    color: var(--xp-text);
    background-color: #ffffcc;
    padding: 8px;
    border: 1px solid var(--xp-border);
    margin-top: 8px;
}

/* Document count text (Showing X-Y of Z...) */
.doc-count-text {
    background: #ffffff;
    padding: 8px;
    font-weight: bold;
    font-size: var(--font-size);
    color: #000000;
    border-bottom: 1px solid var(--xp-border);
    border-right: 1px solid var(--xp-border);
    flex-shrink: 0;
    text-align: center;
}

/* Pagination container */
.doc-pagination-container {
    background: #ffffff;
    border-top: 1px solid #ffffff;
    border-bottom: 1px solid var(--xp-border);
    border-right: 1px solid var(--xp-border);
    flex-shrink: 0;
}

/* Pagination */
.doc-el-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
}

.doc-pagination-btn {
    min-width: 32px;
    padding: 0 8px;
    cursor: pointer;
    font-size: var(--font-size);
    font-weight: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    text-decoration: none;
    user-select: none;
}


.doc-pagination-btn:disabled {
    background-color: #f5f7fa;
    border-color: #e4e7ed;
    color: #c0c4cc;
    cursor: not-allowed;
}

.doc-pagination-info {
    color: #909399;
    font-size: var(--font-size);
    margin: 0 2px;
    white-space: nowrap;
}

ul.tree-view {
    border-right: 1px solid var(--xp-border);
}

ul.tree-view li {
    cursor: pointer;
    margin-top: 6px;
    font-size: var(--font-size);
}

@media (max-width: 700px) {
    html,
    body {
        height: auto;
        min-height: 100%;
    }

    body:has(#doc-viewer-panels) {
        overflow-x: hidden;
        overflow-y: auto;
    }

    #main-content:has(#doc-viewer-panels) {
        height: auto;
        min-height: 100dvh;
        align-items: flex-start;
        overflow: visible;
    }

    #main-content:has(#doc-viewer-panels) .window {
        height: auto !important;
        min-height: 89dvh !important;
        max-height: none !important;
        margin: 3dvh auto !important;
        overflow: visible !important;
    }

    #main-content:has(#doc-viewer-panels) .window-body,
    #doc-viewer-panels {
        overflow: visible;
    }

    #doc-viewer-panels {
        flex: none;
        flex-direction: column !important;
    }

    #doc-left-panel,
    #doc-middle-panel,
    #doc-right-panel {
        width: 100%;
        flex: none;
        overflow: visible;
    }

    #doc-left-panel {
        height: 65dvh;
    }

    #doc-middle-panel #document-viewer {
        min-height: 55dvh;
        overflow: visible;
        border-right: none;
    }

    #doc-right-panel #properties-panel {
        min-height: 35dvh;
        overflow: visible;
    }

    #doc-left-panel .tree-view {
        -webkit-overflow-scrolling: touch;
    }
}
