/* Theme Variables */
:root {
    /* Regular Theme (Default) */
    --bg-color: #f0f0f0;
    --panel-bg: #ffffff;
    --border-color: #333333;
    --button-bg: #e0e0e0;
    --button-hover: #d0d0d0;
    --accent-1: #4a90e2;
    --accent-2: #5da8ff;
    --accent-3: #50c878;
    --delete-color: #e24a4a;
    --text-color: #000000;
    --input-bg: #ffffff;
    --input-text: #000000;
    --list-even: #f8f8f8;
    --tab-inactive-bg: #e0e0e0;
    --tab-active-bg: #4a90e2;
    --tab-hover-bg: #c0c0c0;
    --scrollbar-track: #333333;
    --scrollbar-thumb: #4a90e2;
    --scrollbar-thumb-hover: #5da8ff;
    --info-bg: #ffffff;
    --info-title-bg: #4a90e2;
    --info-title-text: #ffffff;
    --result-bg: #fafafa;
    --result-border: #e0e0e0;
    --success-color: #28a745;
}

.theme-high-contrast {
    --bg-color: #ffffff;
    --panel-bg: #ffffff;
    --border-color: #000000;
    --button-bg: #ffffff;
    --button-hover: #000000;
    --accent-1: #000000;
    --accent-2: #333333;
    --accent-3: #000000;
    --delete-color: #000000;
    --text-color: #000000;
    --input-bg: #ffffff;
    --input-text: #000000;
    --list-even: #f0f0f0;
    --tab-inactive-bg: #d0d0d0;
    --tab-active-bg: #000000;
    --tab-hover-bg: #aaaaaa;
    --scrollbar-track: #ffffff;
    --scrollbar-thumb: #000000;
    --scrollbar-thumb-hover: #333333;
    --info-bg: #ffffff;
    --info-title-bg: #000000;
    --info-title-text: #ffffff;
    --result-bg: #ffffff;
    --result-border: #000000;
    --success-color: #000000;
}

.theme-dark {
    --bg-color: #1a1a1a;
    --panel-bg: #2d2d2d;
    --border-color: #404040;
    --button-bg: #404040;
    --button-hover: #505050;
    --accent-1: #4a90e2;
    --accent-2: #5da8ff;
    --accent-3: #50c878;
    --delete-color: #ff6b6b;
    --text-color: #ffffff;
    --input-bg: #404040;
    --input-text: #ffffff;
    --list-even: #363636;
    --tab-inactive-bg: #404040;
    --tab-active-bg: #4a90e2;
    --tab-hover-bg: #505050;
    --scrollbar-track: #404040;
    --scrollbar-thumb: #4a90e2;
    --scrollbar-thumb-hover: #5da8ff;
    --info-bg: #2d2d2d;
    --info-title-bg: #4a90e2;
    --info-title-text: #ffffff;
    --result-bg: #383838;
    --result-border: #505050;
    --success-color: #50c878;
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Times New Roman', Times, serif;
    background-color: var(--bg-color);
    padding: 20px;
    color: var(--text-color);
    transition: all 0.3s ease;
    min-height: 100vh;
    position: relative;
}

/* Corner Buttons */
.corner-btn {
    position: absolute;
    padding: 8px 16px;
    background-color: var(--accent-1);
    color: white;
    text-decoration: none;
    border: 2px solid var(--border-color);
    font-family: 'Times New Roman', Times, serif;
    font-size: 14px;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.2s ease;
    border-radius: 0;
}

.corner-btn:hover {
    background-color: var(--accent-2);
}

.return-btn {
    top: 20px;
    left: 20px;
}

.theme-btn {
    top: 20px;
    right: 20px;
}

/* Main Container */
.main-container {
    max-width: 1200px;
    margin: 55px auto 20px;
    background-color: var(--panel-bg);
    border: 2px solid var(--border-color);
    border-radius: 0;
    display: flex;
    flex-direction: column;
}

.title-bar {
    background-color: var(--accent-1);
    color: white;
    padding: 12px 20px;
    font-weight: bold;
    font-size: 18px;
    border-bottom: 2px solid var(--border-color);
    text-align: left;
    flex-shrink: 0;
}

/* Template Content Styles */
.template-content {
    padding: 30px;
    min-height: 500px;
    flex-grow: 1;
}

.template-content h2 {
    color: var(--accent-1);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent-1);
}

.template-content p {
    margin-bottom: 15px;
    line-height: 1.6;
}

.template-features {
    margin-top: 25px;
    padding: 15px;
    background-color: var(--list-even);
    border-left: 4px solid var(--accent-1);
}

.template-features h3 {
    margin-bottom: 10px;
    color: var(--accent-2);
}

.template-features ul {
    padding-left: 20px;
    margin-bottom: 15px;
}

.template-features li {
    margin-bottom: 8px;
    line-height: 1.5;
}

/* Info Section */
.info-section {
    width: 900px;
    height: 350px;
    margin: 20px auto 20px;
    border: 2px solid var(--border-color);
    background-color: var(--info-bg);
    border-radius: 0;
    display: flex;
    flex-direction: column;
}

.info-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    background-color: var(--list-even);
    flex-shrink: 0;
}

.info-tab-btn {
    flex: 1;
    padding: 12px 20px;
    background-color: var(--tab-inactive-bg);
    border: none;
    cursor: pointer;
    font-family: 'Times New Roman', Times, serif;
    font-size: 15px;
    font-weight: bold;
    color: var(--text-color);
    transition: all 0.2s ease;
    border-right: 1px solid var(--border-color);
    border-radius: 0;
}

.info-tab-btn:last-child {
    border-right: none;
}

.info-tab-btn:hover {
    background-color: var(--tab-hover-bg);
}

.info-tab-btn.active {
    background-color: var(--tab-active-bg);
    color: white;
}

.info-tab-content {
    display: none;
    padding: 20px;
    flex: 1;
    overflow: hidden;
}

.info-tab-content.active {
    display: block;
}

.info-content-scroll {
    height: 100%;
    overflow-y: auto;
    padding-right: 10px;
}

/* Scrollbar styling */
.info-content-scroll::-webkit-scrollbar {
    width: 8px;
}

.info-content-scroll::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    opacity: 0.3;
}

.info-content-scroll::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border: 1px solid var(--border-color);
}

.info-content-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

.info-content-scroll {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.info-content-scroll h4 {
    margin: 16px 0 8px 0;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--border-color);
    color: var(--accent-1);
    font-size: 16px;
}

.info-content-scroll h4:first-of-type {
    margin-top: 0;
}

.info-content-scroll p {
    margin-bottom: 12px;
    line-height: 1.5;
    font-size: 13px;
    color: var(--text-color);
}

.info-content-scroll ul {
    margin: 8px 0 12px 25px;
    line-height: 1.5;
    font-size: 13px;
    color: var(--text-color);
}

.info-content-scroll li {
    margin-bottom: 4px;
}

.info-content-scroll strong {
    color: var(--accent-1);
}

.info-content-scroll a {
    color: var(--accent-1);
    text-decoration: none;
    font-size: 13px;
}

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

/* Footer */
.footer-container {
    max-width: 1200px;
    margin: 20px auto 0;
    text-align: center;
    padding: 12px;
}

.copyright-footer {
    margin-bottom: 8px;
    color: var(--text-color);
    opacity: 0.7;
    font-size: 14px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.footer-links a {
    color: var(--accent-1);
    text-decoration: none;
    font-size: 13px;
}

.footer-links a:hover {
    text-decoration: underline;
}

/* Button Styles */
button {
    padding: 8px 12px;
    background: var(--button-bg);
    border: 2px solid var(--border-color);
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-color);
    transition: all 0.2s ease;
    border-radius: 0;
}

button:hover {
    background: var(--button-hover);
}

button:active {
    transform: translate(1px, 1px);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-container {
        max-width: 95%;
    }
    
    .info-section {
        width: 95%;
        max-width: 900px;
        height: 300px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .corner-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .return-btn {
        top: 10px;
        left: 10px;
    }
    
    .theme-btn {
        top: 10px;
        right: 10px;
    }
    
    .main-container {
        margin-top: 50px;
        max-width: 100%;
    }
    
    .template-content {
        padding: 15px;
        min-height: 350px;
    }
    
    .info-section {
        width: 100%;
        height: 350px;
        max-width: 100%;
    }
    
    .info-tabs {
        flex-direction: column;
    }
    
    .info-tab-btn {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .info-tab-btn:last-child {
        border-bottom: none;
    }
}

@media (max-width: 480px) {
    .title-bar {
        font-size: 16px;
        padding: 10px;
    }
    
    .template-content {
        padding: 15px;
        min-height: 300px;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 8px;
    }
    
    .info-tab-btn {
        padding: 10px;
        font-size: 13px;
    }
    
    .info-section {
        height: 400px;
    }
}

/* Compressor Layout */
.main-container {
    min-height: 0;
}

.app-grid {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    grid-template-rows: 300px 360px;
    gap: 0;
    flex-grow: 1;
}

.pane {
    padding: 18px;
    min-width: 0;
}

.pane h2 {
    color: var(--accent-1);
    font-size: 18px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--accent-1);
}

/* Options Pane (left) */
.pane-options {
    grid-row: 1 / span 2;
    padding: 12px;
    border-right: 2px solid var(--border-color);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.pane-options h2 {
    font-size: 16px;
    margin-bottom: 8px;
    padding-bottom: 6px;
}

/* Drop Zone */
.dropzone {
    padding: 30px 10px;
    border: 2px dashed var(--border-color);
    background: var(--list-even);
    text-align: center;
    transition: background 0.2s;
}

.dropzone.over {
    background: var(--result-bg);
    border-color: var(--accent-1);
}

.dropzone p {
    font-size: 14px;
    margin-bottom: 6px;
}

.dz-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
    margin: 6px 0 0;
}

.dz-buttons button {
    padding: 5px 10px;
    font-size: 13px;
}

/* Compression Controls */
.controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.controls label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 13px;
    font-weight: bold;
}

.controls select,
.controls input[type="number"] {
    padding: 4px 6px;
    border: 2px solid var(--border-color);
    border-radius: 0;
    background: var(--input-bg);
    color: var(--input-text);
    font-family: inherit;
    font-size: 13px;
}

.controls small {
    font-size: 11px;
    font-weight: normal;
    line-height: 1.2;
    opacity: 0.75;
}

#speedNote {
    margin-top: 2px;
}

/* Action Buttons (Test Speed, Compress, Compare, Clear, Download) */
.btn-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.act-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 36px;
    padding: 0 8px;
    border: 2px solid var(--border-color);
    border-radius: 0;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 14px;
    line-height: 1;
    text-align: center;
    text-decoration: none;
}

/* Shared accent styling for action + picker buttons */
.act-btn,
.dz-buttons button {
    background-color: var(--accent-1);
    color: white;
    border: 2px solid var(--border-color);
    transition: all 0.2s ease;
}

.act-btn:hover,
.dz-buttons button:hover {
    background-color: var(--accent-2);
}

.dl-link {
    background-color: var(--accent-1);
    color: white;
    font-weight: bold;
    cursor: pointer;
}

.dl-link:hover {
    background-color: var(--accent-2);
    filter: none;
}

/* Hidden Download button keeps its space so the layout never shifts */
.dl-link[style*="none"] {
    display: flex !important;
    visibility: hidden;
}

.status {
    min-height: 14px;
    margin: 4px 0 0;
    font-size: 11px;
    font-style: italic;
    line-height: 1.3;
}

/* Results Pane (top right) */
.pane-results {
    height: 300px;
    border-bottom: 2px solid var(--border-color);
    overflow-y: auto;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
    border: 2px solid var(--border-color);
    background: var(--result-bg);
}

.card span {
    font-size: 12px;
    opacity: 0.8;
}

.card b {
    font-size: 17px;
    color: var(--accent-1);
}

.note {
    font-size: 12px;
    opacity: 0.8;
}

/* Results Tables */
.table-wrap {
    max-height: 400px;
    margin-top: 15px;
    margin-bottom: 10px;
    overflow-x: auto;
    overflow-y: auto;
}

.table-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table-wrap th,
.table-wrap td {
    padding: 6px 10px;
    border: 1px solid var(--result-border);
    text-align: left;
}

.table-wrap th {
    position: sticky;
    top: 0;
    background: var(--info-title-bg);
    color: var(--info-title-text);
}

.table-wrap tr.best td {
    background: var(--list-even);
    font-weight: bold;
}

.table-wrap tr.est td {
    font-style: italic;
    opacity: 0.85;
}

.table-wrap.compact {
    max-height: none;
}

.table-wrap.compact table {
    font-size: 12px;
    line-height: 1.2;
}

.table-wrap.compact th,
.table-wrap.compact td {
    padding: 2px 8px;
    white-space: nowrap;
}

/* File Preview Pane (bottom right) */
.pane-preview {
    height: 360px;
    display: flex;
    flex-direction: column;
}

.pv-split {
    display: flex;
    flex: 1;
    min-height: 0;
    border: 1px solid var(--result-border);
}

.empty {
    margin: auto;
    padding: 12px;
    font-size: 14px;
    text-align: center;
    opacity: 0.8;
}

/* File List */
.file-list {
    width: 60%;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-right: 1px solid var(--result-border);
    font-size: 13px;
    overflow-y: auto;
}

.file-list:empty {
    display: block;
}

.list-head {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    padding: 6px 10px;
    background: var(--list-even);
    font-weight: bold;
}

.list-row {
    display: flex;
    flex-shrink: 0;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 10px;
    border-top: 1px solid var(--result-border);
    word-break: break-all;
    cursor: pointer;
}

.list-row:hover {
    background: var(--list-even);
}

.list-row.selected {
    background: var(--accent-1);
    color: #fff;
}

.list-row.selected button {
    color: var(--text-color);
}

.list-row.folder {
    background: var(--list-even);
    font-weight: bold;
}

.list-row.folder:hover {
    background: var(--result-bg);
}

.list-row button {
    margin-left: 6px;
    padding: 0 6px;
    font-size: 12px;
}

/* File Info Sheet */
.pv-view {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--result-bg);
    overflow: auto;
}

.pv-inner {
    flex-shrink: 0;
    padding: 12px;
}

.pv-inner h3 {
    margin: 10px 0 6px;
    padding-bottom: 3px;
    border-bottom: 1px solid var(--result-border);
    color: var(--accent-1);
    font-size: 13px;
}

.pv-inner h3:first-child {
    margin-top: 0;
}

.kv {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 3px 0;
    border-bottom: 1px dotted var(--result-border);
    font-size: 12px;
}

.kv span {
    flex-shrink: 0;
    opacity: 0.8;
}

.kv b {
    font-weight: normal;
    text-align: right;
    word-break: break-all;
}

/* High Contrast Theme Fixes */
.theme-high-contrast button:not(.info-tab-btn):hover {
    background: #000000;
    color: #ffffff;
}

.theme-high-contrast .dl-link {
    background: #000000;
    color: #ffffff;
}

.theme-high-contrast .dl-link:hover {
    background: #ffffff;
    color: #000000;
    filter: none;
}

/* Responsive Design (Compressor) */
@media (max-width: 900px) {
    .app-grid {
        grid-template-columns: 1fr;
        grid-template-rows: none;
        grid-auto-rows: auto;
    }

    .pane-options {
        grid-row: auto;
        border-right: none;
        border-bottom: 2px solid var(--border-color);
        overflow-y: visible;
    }

    .pane-preview {
        height: 420px;
    }

    .pv-split {
        flex-direction: column;
    }

    .file-list {
        width: 100%;
        max-height: 150px;
        border-right: none;
        border-bottom: 1px solid var(--result-border);
    }
}