/* root / css / main.css */

/* =========================================
   1. FONTS & RESET
========================================= */
@font-face { src: url("../assets/jetbrains-mono.ttf");  font-family: "JetBrains Mono"; }

* { margin: 0; padding: 0; box-sizing: border-box; scrollbar-gutter: stable both-edges; user-select: none; }
*:not(a, button, input, th, a > strong, .hash-icon, .clickable, label) { cursor: default !important; }
html { scroll-behavior: smooth; }

input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus, input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0px 1000px var(--bg-light) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important; caret-color: white !important;
}

/* =========================================
   2. CSS VARIABLES
========================================= */
:root {
    --accent: #9f7aea; --accent-light: #d6bcfa;
    --bg-dark: #0f0f12; --bg-light: #1a1a1f;
    --text-primary: #e8e8ed; --text-secondary: #b0b0b8;
    --color-red: #f7768e; --color-orange: #ff9e64; --color-yellow: #e0af68;
    --color-green: #9ece6a; --color-lime: #b9f27c;
    --size-c1: #a6d189; --size-c2: #e5c890; --size-c3: #ef9f76; --size-c4: #e78284;
    --size-c5: #ea999c; --size-c6: #ca9ee6; --size-c7: #85c1dc; --size-c8: #99d1db;
    --badge-text-color: #0f0f12; --code-highlight: #d2fafa;
}

/* =========================================
   3. GLOBAL STYLES & NAV
========================================= */
body {
    font-family: "JetBrains Mono", monospace; background-color: var(--bg-dark); color: var(--text-primary);
    min-height: 100vh; display: flex; flex-direction: column; align-items: center; line-height: 1.6; overflow-x: hidden;
}

/* App Settings Overrides */
body.hide-emojis .emoji { display: none; }
body.compact-mode .report-table td { padding: 0.25rem 1rem; }
body.simple-badges .size-badge {
    background-color: var(--bg-dark) !important;
    color: var(--text-primary) !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

a[href] { color: var(--accent); text-decoration: none; transition: all 0.3s ease; }
a[href]:hover { color: var(--accent-light); }

.nav-container { width: 100%; position: fixed; top: 0; left: 0; z-index: 100; }

.nav {
    background: rgba(20, 20, 25, 0.92); backdrop-filter: blur(16px);
    display: flex; justify-content: center; padding: 1.3rem 0px; gap: 2rem; flex-wrap: wrap; width: 100%;
    outline: 1px solid var(--bg-dark);
}

.nav a { color: var(--text-secondary); text-decoration: none; font-size: 0.9rem; transition: all 0.3s ease; position: relative; }
.nav a:hover { color: var(--accent-light); }

.sub-nav {
    background: rgba(32, 32, 37, 0.5); backdrop-filter: blur(16px);
    display: flex; justify-content: center; align-items: center; flex-wrap: wrap;
    padding: 0.8rem 0; gap: 2rem; width: 100%; border-bottom: 1px solid rgba(255,255,255,0.05);
}
.sub-nav a { color: var(--text-secondary); font-size: 0.85rem; position: relative; }
.sub-nav a:hover, .sub-nav a.active { color: var(--accent-light); }
.sub-nav a.active::after { content: ''; position: absolute; bottom: -5px; left: 0; width: 100%; height: 2px; background: var(--accent); }

@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(159, 122, 234, 0.5); } 70% { box-shadow: 0 0 0 8px rgba(159, 122, 234, 0); } 100% { box-shadow: 0 0 0 0 rgba(159, 122, 234, 0); } }
.btn-pulse { animation: pulse 2s infinite; background: rgba(159,122,234,0.15); color: var(--accent-light) !important; padding: 0.3rem 0.8rem; border-radius: 4px; border: 1px solid var(--accent); cursor: pointer !important; }

/* API-Reference Page */
.endpoint { background: var(--bg-light); border-left: 3px solid var(--accent); padding: 1.5rem; margin-bottom: 1.5rem; border-radius: 0.375rem; }
.endpoint h3 { margin-bottom: 0.5rem; font-family: monospace; font-size: 1.2rem; }
.endpoint h3 a { color: var(--accent); text-decoration: underline dotted; word-break: break-all; }
.endpoint h3 a:hover { color: var(--accent-light); }
.endpoint p { color: var(--text-secondary); margin-bottom: 1rem; font-size: 0.9rem; }
.code-block { background: var(--bg-dark); padding: 1rem; border-radius: 0.25rem; font-family: monospace; font-size: 0.85rem; color: var(--color-green); overflow-x: auto; border: 1px solid rgba(255,255,255,0.05); }
code { color: var(--code-highlight) }

/* =========================================
   4. LAYOUT & ACCORDIONS
========================================= */
.container { padding-top: 8rem; width: 100%; max-width: 1400px; padding-left: 2rem; padding-right: 2rem; }
.hero { text-align: center; margin-bottom: 2rem; }
.title { 
    font-size: clamp(1.8rem, 6vw, 4rem);
    font-weight: 500;
    color: var(--accent);
    white-space: normal;
    text-align: center;
    min-height: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tagline { color: var(--text-secondary); font-size: 0.95rem; letter-spacing: 0.05em; }

.accordion { background-color: var(--bg-light); border-left: 3px solid var(--accent); padding: 1.2rem 1.5rem; border-radius: 0.375rem; margin-bottom: 1.5rem; transition: all 0.25s ease; }
.accordion .header { font-size: 1.1rem; font-weight: 500; color: var(--accent); display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.accordion .header::after { content: "▼"; font-size: 0.9rem; transition: transform 0.3s ease; }
.accordion.open .header::after { transform: rotate(180deg); }
.accordion .content { max-height: 0; opacity: 0; overflow: hidden; transition: max-height 0.4s ease, opacity 0.3s ease, margin 0.3s ease; }
.accordion.open .content { max-height: 2500px; opacity: 1; margin-top: 1.5rem; overflow: visible; }

/* =========================================
   5. TOOLTIPS & SUMMARY
========================================= */
.tooltip-container { position: relative; display: inline-block; cursor: help !important; border-bottom: 1px dotted var(--text-secondary); }
.tooltip-container .tooltip-text {
    visibility: hidden; background-color: var(--bg-light); color: var(--accent-light);
    text-align: center; border-radius: 6px; padding: 0.5rem 0.8rem; position: absolute; z-index: 10;
    bottom: 125%; left: 50%; transform: translateX(-50%); opacity: 0; transition: opacity 0.3s;
    border: 1px solid var(--accent); font-size: 0.8rem; font-weight: normal; white-space: nowrap;
    box-shadow: 0px 4px 12px rgba(0,0,0,0.5);
}
.tooltip-container:hover .tooltip-text { visibility: visible; opacity: 1; }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
.summary-card { background: rgba(15, 15, 18, 0.4); padding: 1.25rem; border-radius: 0.375rem; border: 1px solid rgba(255,255,255,0.05); }
.summary-label { font-size: 0.85rem; color: var(--accent-light); text-transform: uppercase; font-weight: 600; display: block; margin-bottom: 0.75rem; border-bottom: 1px solid rgba(159, 122, 234, 0.2); padding-bottom: 0.25rem; }

.stat-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; margin-bottom: 0.2rem; }
.stat-row span { color: var(--text-secondary); }

/* Difference Metrics */
.diff-container { font-size: 0.85em; color: var(--text-secondary); font-weight: normal; }
.diff-positive { color: var(--color-green) !important; }
.diff-negative { color: var(--color-red) !important; }
.diff-neutral { color: var(--text-secondary) !important; }

.text-accent { color: var(--accent); } .text-lime { color: var(--color-lime); }
.text-green { color: var(--color-green); } .text-orange { color: var(--color-orange); }
.text-red { color: var(--color-red); } .text-yellow { color: var(--color-yellow); }

/* =========================================
   6. FILTERS & SEARCH
========================================= */

.filter-row { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid rgba(255,255,255,0.03); }
.filter-row:last-child { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }

.filter-label-col { width: 70px; flex-shrink: 0; padding-top: 0.4rem; }
.filter-btn-col { display: flex; flex-wrap: wrap; gap: 0.6rem; flex: 1; }

.filter-label { display: inline-block; font-size: 0.8rem; color: var(--text-secondary); text-transform: uppercase; font-weight: 600; }

.clickable { cursor: pointer !important; color: var(--accent); border-bottom: 1px dotted var(--accent); padding-bottom: 2px; max-width: max-content; }
.clickable:hover { color: var(--accent-light); }

.filter-btn, .reset-btn, .icon-btn { position: relative; background-color: var(--bg-dark); color: var(--text-primary); border: 1px solid rgba(255,255,255,0.1); padding: 0.4rem 0.8rem; font-size: 0.85rem; font-family: "JetBrains Mono", monospace; border-radius: 0.25rem; cursor: pointer !important; transition: all 0.2s ease; }
.filter-btn:hover, .icon-btn:hover { border-color: var(--accent); color: white; }
.filter-btn.active { background-color: var(--accent); color: #fff; font-weight: bold;}
.icon-btn { font-size: 1.1rem; padding: 0.4rem 0.6rem; display: flex; align-items: center; justify-content: center; }

.search-row { display: flex; gap: 1rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed rgba(159, 122, 234, 0.3); }
input[type="search"] { flex-grow: 1; background-color: var(--bg-dark); color: var(--text-primary); border: 1px solid rgba(255,255,255,0.2); padding: 0.6rem 1rem; font-size: 0.95rem; font-family: inherit; border-radius: 0.25rem; cursor: text !important; }
input[type="search"]:focus { outline: none; border-color: var(--accent); }
.reset-btn { background-color: rgba(247, 118, 142, 0.1); color: var(--color-red); border-color: var(--color-red); padding: 0.6rem 1.5rem; }
.reset-btn:hover { background-color: var(--color-red); color: var(--bg-dark); }

/* =========================================
   7. TABLE & MODALS
========================================= */
.report-container { background-color: var(--bg-light); border-radius: 0.375rem; overflow-x: auto; margin-bottom: 3rem; border-left: 3px solid var(--accent); }
.report-table { width: 100%; border-collapse: collapse; text-align: left; }
.report-table thead { background-color: rgba(15, 15, 18, 0.7); }
.report-table th { padding: 1rem; color: var(--accent); font-weight: 500; font-size: 0.9rem; cursor: pointer !important; white-space: nowrap; position: relative; border-bottom: 1px solid rgba(255,255,255,0.05); }
.report-table th.sortable::after { content: '\2195'; position: absolute; right: 0.5rem; opacity: 0.2; }
.report-table th.sort-asc::after { content: '\2191'; opacity: 1; color: var(--text-primary); }
.report-table th.sort-desc::after { content: '\2193'; opacity: 1; color: var(--text-primary); }

.report-table tbody tr { border-bottom: 1px solid rgba(255,255,255,0.03); transition: background 0.1s; cursor: pointer !important; }
.report-table tbody tr:hover { background: rgba(159, 122, 234, 0.08); }
.report-table td { padding: 0.6rem 1rem; white-space: nowrap; font-size: 0.9rem; transition: padding 0.2s ease; }

.col-name { max-width: 400px; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); user-select: text; }
.hash-icon { color: var(--text-secondary); background: var(--bg-dark); padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.8em; cursor: pointer !important; transition: all 0.2s; border: 1px solid rgba(255,255,255,0.1); margin-right: 0.5rem; z-index: 2; position: relative;}
.hash-icon:hover { color: var(--bg-dark); background: var(--accent); border-color: var(--accent); }
.hash-icon.copied { background: var(--color-green); border-color: var(--color-green); color: var(--bg-dark); }

.size-badge { padding: 0.2em 0.5em; border-radius: 0.25rem; font-weight: 600; font-size: 0.85em; color: var(--badge-text-color); display: inline-block; transition: all 0.2s; }
.sb-1{background:var(--size-c1)} .sb-2{background:var(--size-c2)} .sb-3{background:var(--size-c3)} .sb-4{background:var(--size-c4)} .sb-5{background:var(--size-c5)} .sb-6{background:var(--size-c6)} .sb-7{background:var(--size-c7)} .sb-8{background:var(--size-c8)}

.seeders { color: var(--color-lime); font-weight: bold; } .seeders-zero { color: var(--color-red); font-weight: bold; }
.col-ratio { text-align: center; font-weight: bold; }
.ratio-excellent { color: var(--color-green); } .ratio-great { color: var(--color-lime); } .ratio-good { color: var(--color-yellow); } .ratio-ok { color: var(--color-orange); } .ratio-poor { color: var(--color-red); }

#toTopBtn { display: none; position: fixed; bottom: 20px; right: 20px; background: var(--accent); color: var(--bg-dark); padding: 0.6rem 1rem; border-radius: 0.25rem; border: none; cursor: pointer !important; font-family: inherit; font-weight: 600; box-shadow: 0 4px 12px rgba(0,0,0,0.3); z-index: 1000; transition: transform 0.2s; }
#toTopBtn:hover { transform: translateY(-3px); }

/* Graphs & Modals */
.chart-grid { display: grid; grid-template-columns: 1fr; gap: 2rem; margin-bottom: 2rem;}
@media (min-width: 1024px) { .chart-grid { grid-template-columns: 1fr 1fr; } }
.chart-box { background: var(--bg-light); border: 1px solid rgba(255,255,255,0.05); border-radius: 0.5rem; padding: 1.5rem; position: relative; height: 400px; }

/* Modal Animations */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.8); backdrop-filter: blur(5px); z-index: 2000; display: none; justify-content: center; align-items: center; opacity: 0; transition: opacity 0.2s ease-out; cursor: pointer !important; }
.modal-overlay.active { display: flex; opacity: 1; }
.modal-box { background: var(--bg-light); padding: 2rem; border-radius: 0.5rem; max-width: 600px; width: 90%; position: relative; border: 1px solid var(--accent); cursor: default !important; max-height: 90vh; overflow-y: auto; transform: scale(0.95); opacity: 0; transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease-out; }
.modal-overlay.active .modal-box { transform: scale(1); opacity: 1; }

.modal-close { position: absolute; top: 1rem; right: 1rem; background: transparent; border: none; color: var(--text-secondary); font-size: 1.5rem; cursor: pointer !important; }
.modal-close:hover { color: var(--color-red); }
.modal-title { color: var(--accent); margin-bottom: 1rem; font-size: 1.3rem; hyphens: auto;}

.modal-box ul { list-style-type: disc; padding-left: 1.5rem; margin-top: 1rem; }
.modal-box li { margin-bottom: 0.5rem; display: list-item; }
.modal-box ul li::marker { color: var(--accent); }

/* Settings Toggles */
.setting-row { display: flex; justify-content: space-between; align-items: center; padding: 0.8rem 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.setting-row:last-child { border-bottom: none; }
.setting-info { flex: 1; padding-right: 1rem; }
.setting-title { font-weight: bold; color: var(--text-primary); display: block; margin-bottom: 0.2rem; }
.setting-desc { font-size: 0.8rem; color: var(--text-secondary); }

/* Checkbox Toggle Switch UI */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; cursor: pointer !important;}
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer !important; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.1); transition: .3s; border-radius: 24px; border: 1px solid rgba(255,255,255,0.2); }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: var(--text-secondary); transition: .3s; border-radius: 50%; }
input:checked + .slider { background-color: var(--accent); border-color: var(--accent); }
input:checked + .slider:before { transform: translateX(20px); background-color: white; }

@media (max-width: 768px) {
    .nav, .sub-nav { padding: 1rem; gap: 1rem; }
    .container { padding-left: 1rem; padding-right: 1rem; padding-top: 10rem; }
    .summary-grid { grid-template-columns: 2fr; }
    .search-row { flex-direction: column; }
    .col-name { max-width: 100%; }
    
    .filter-row { flex-direction: column; gap: 0.5rem; }
    
    .report-table thead { display: none; }
    .report-table, .report-table tbody, .report-table tr, .report-table td { display: block; width: 100%; }
    .report-table tr { margin-bottom: 1rem; border: 1px solid rgba(255,255,255,0.1); border-radius: 0.375rem; }
    .report-table td { text-align: right; padding-left: 50%; position: relative; border-bottom: 1px solid rgba(255,255,255,0.05); white-space: normal; }
    .report-table td::before { content: attr(data-label); position: absolute; left: 1rem; font-weight: bold; color: var(--accent); font-size: 0.8em; text-transform: uppercase; }
    .report-table tr td.col-name { padding: 1rem; text-align: left; background: rgba(0,0,0,0.2); font-size: 1.05em; font-weight: bold; display: block; }
    .report-table tr td.col-name::before { display: none; }
    
    #toTopBtn { left: 50%; transform: translateX(-50%); right: auto; bottom: 20px; }
    #toTopBtn:hover { transform: translate(-50%, -3px); }
}