/* ==========================================================================
   RAPEDIT SEARCH - B&W SKEUOMORPHIC 2012
   ========================================================================== */

body, input, button, select, textarea {
    font-family: Arial, "Helvetica Neue", Helvetica, Tahoma, sans-serif;
    font-size: 13px;
}

:root {
    --bg: #e8e8e8;
    --bg-surface: linear-gradient(to bottom, #ffffff 0%, #e6e6e6 100%);
    --bg-elevated: linear-gradient(to bottom, #fafafa 0%, #e8e8e8 100%);
    --text: #222;
    --text-muted: #555;
    --text-dim: #888;
    --border: #b0b0b0;
    --border-strong: #999;
    --border-bevel: #fff;
    --accent: #444;
    --accent-dim: #222;
    --shadow: 0 3px 10px rgba(0,0,0,0.12), inset 0 1px 0 var(--border-bevel);
    --btn-bg: linear-gradient(to bottom, #ffffff 0%, #e8e8e8 100%);
    --btn-active: linear-gradient(to bottom, #e8e8e8 0%, #ffffff 100%);
}

[data-theme="dark"] {
    --bg: #181818;
    --bg-surface: linear-gradient(to bottom, #2b2b2b 0%, #1a1a1a 100%);
    --bg-elevated: linear-gradient(to bottom, #353535 0%, #202020 100%);
    --text: #e0e0e0;
    --text-muted: #aaa;
    --text-dim: #777;
    --border: #444;
    --border-strong: #555;
    --border-bevel: rgba(255,255,255,0.08);
    --accent: #ccc;
    --accent-dim: #999;
    --shadow: 0 4px 12px rgba(0,0,0,0.4), inset 0 1px 0 var(--border-bevel);
    --btn-bg: linear-gradient(to bottom, #353535 0%, #202020 100%);
    --btn-active: linear-gradient(to bottom, #202020 0%, #353535 100%);
}

/* Scrollbar */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track {
    background: var(--bg);
    border-left: 1px solid var(--border);
    box-shadow: inset 1px 0 3px rgba(0,0,0,0.08);
}
::-webkit-scrollbar-thumb {
    background: linear-gradient(to right, #d0d0d0, #b0b0b0);
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    box-shadow: inset 1px 1px 0 rgba(255,255,255,0.2);
}
[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: linear-gradient(to right, #444, #333);
    border: 1px solid #222;
}

html, body {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    transition: background 0.3s ease;
}

/* 2012 scanlines overlay */
body::before {
    content: "";
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0,0,0,0.02),
        rgba(0,0,0,0.02) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
    z-index: 999;
}
[data-theme="dark"] body::before {
    background: repeating-linear-gradient(
        0deg,
        rgba(255,255,255,0.015),
        rgba(255,255,255,0.015) 1px,
        transparent 1px,
        transparent 3px
    );
}

a { color: var(--text); text-decoration: underline; }
a:hover { color: var(--accent); }

/* --- LAYOUT --- */
.app {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 100vh;
}

/* --- HEADER --- */
.hdr {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border) !important;
    border-bottom: 3px solid var(--border-strong) !important;
    border-radius: 5px;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.hdr-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hdr-title {
    font-size: 20px;
    font-weight: bold;
    color: var(--text);
    text-shadow: 1px 1px 0 rgba(255,255,255,0.8);
}
[data-theme="dark"] .hdr-title {
    text-shadow: 1px 1px 0 rgba(0,0,0,0.6);
}

.hdr-sub {
    font-size: 10px;
    color: var(--text-dim);
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: -2px;
}

.hdr-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- BUTTONS --- */
.btn {
    background: var(--btn-bg);
    border: 1px solid var(--border);
    border-bottom: 2px solid var(--border-strong);
    border-radius: 3px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: bold;
    color: var(--text);
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 1px 2px rgba(0,0,0,0.1);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.1s ease;
}

.btn:hover {
    background: var(--bg-elevated);
    border-color: var(--border-strong);
}

.btn:active {
    background: var(--btn-active);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
    transform: translateY(1px);
}

.btn--sm {
    padding: 4px 8px;
    font-size: 11px;
}

.btn--accent {
    background: linear-gradient(to bottom, #555 0%, #222 100%);
    border-color: #111;
    border-bottom-color: #000;
    color: #fff;
}
.btn--accent:hover {
    background: linear-gradient(to bottom, #666 0%, #333 100%);
}
.btn--accent:active {
    background: linear-gradient(to bottom, #222 0%, #444 100%);
}
[data-theme="dark"] .btn--accent {
    background: linear-gradient(to bottom, #777 0%, #444 100%);
    border-color: #333;
    border-bottom-color: #222;
}
[data-theme="dark"] .btn--accent:hover {
    background: linear-gradient(to bottom, #888 0%, #555 100%);
}

/* --- SEARCH SECTION --- */
.search-section {
    padding: 20px;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    background: var(--bg-surface) !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow);
}

.search-heading {
    margin: 0;
    font-size: 20px;
    font-weight: bold;
    color: var(--text);
    text-shadow: 0 1px 0 rgba(255,255,255,0.8);
}
[data-theme="dark"] .search-heading {
    text-shadow: 0 1px 0 rgba(0,0,0,0.6);
}

.search-sub {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    margin: -4px 0 4px 0;
    max-width: 600px;
    line-height: 1.4;
    text-shadow: 0 1px 0 rgba(255,255,255,0.8);
}
[data-theme="dark"] .search-sub {
    text-shadow: 0 1px 0 rgba(0,0,0,0.6);
}

.search-bar {
    width: 100%;
    max-width: 600px;
    display: flex;
    border-radius: 4px;
    background: #fff;
    border: 1px solid var(--border-strong);
    padding: 3px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.12);
}
[data-theme="dark"] .search-bar {
    background: #252525;
    border-color: #555;
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px 12px;
    font-size: 14px;
    color: var(--text);
}
.search-input:focus { outline: none; }

.search-submit {
    background: linear-gradient(to bottom, #555 0%, #222 100%);
    border: 1px solid #111;
    border-bottom: 2px solid #000;
    border-radius: 3px;
    padding: 0 16px;
    font-size: 13px;
    font-weight: bold;
    color: #fff;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 1px 2px rgba(0,0,0,0.2);
}
.search-submit:hover {
    background: linear-gradient(to bottom, #666 0%, #333 100%);
}
[data-theme="dark"] .search-submit {
    background: linear-gradient(to bottom, #777 0%, #444 100%);
    border-color: #333;
}

/* --- TABS --- */
.tabs {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 5px;
    border-bottom: 1px solid var(--border);
    width: 100%;
}

.tab {
    padding: 6px 14px;
    border-radius: 4px 4px 0 0;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    background: linear-gradient(to bottom, #f0f0f0 0%, #ddd 100%);
    border: 1px solid var(--border);
    border-bottom: none;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: -1px;
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 0 #fff;
    box-shadow: inset 0 1px 0 #fff;
    transition: all 0.1s ease;
}
[data-theme="dark"] .tab {
    background: linear-gradient(to bottom, #2b2b2b 0%, #1e1e1e 100%);
    color: #888;
    text-shadow: 0 1px 0 #000;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.tab:hover {
    background: linear-gradient(to bottom, #fff 0%, #eee 100%);
    color: var(--text);
}
[data-theme="dark"] .tab:hover {
    background: linear-gradient(to bottom, #3a3a3a 0%, #2b2b2b 100%);
    color: #eee;
}

.tab.active {
    background: var(--bg) !important;
    border: 1px solid var(--border) !important;
    border-bottom: 2px solid var(--bg) !important;
    color: var(--text) !important;
    padding-bottom: 7px;
    margin-bottom: -2px;
    z-index: 2;
    box-shadow: inset 0 2px 0 var(--border-strong) !important;
}
[data-theme="dark"] .tab.active {
    border-bottom-color: var(--bg) !important;
    box-shadow: inset 0 2px 0 var(--border-strong) !important;
}

/* --- RESULTS GRID --- */
.results {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    width: 100%;
}

.results--single {
    grid-template-columns: 1fr;
    max-width: 900px;
    margin: 0 auto;
}

/* --- COLUMN PANELS --- */
.col-panel {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 4px !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 650px;
    box-shadow: var(--shadow) !important;
}

.col-hdr {
    background: var(--bg-elevated);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: inset 0 1px 0 var(--border-bevel);
}

.col-title {
    font-size: 13px;
    font-weight: bold;
    color: var(--text);
    text-shadow: 0 1px 0 rgba(255,255,255,0.8);
}
[data-theme="dark"] .col-title {
    text-shadow: 0 1px 0 rgba(0,0,0,0.6);
}

.col-count {
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(0,0,0,0.05);
    border: 1px solid var(--border);
    color: var(--text-muted);
}
[data-theme="dark"] .col-count {
    background: rgba(255,255,255,0.05);
}

.col-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--bg);
}

/* --- RESULT CARDS --- */
.card {
    border-radius: 3px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: all 0.1s ease;
}

.card:hover {
    border-color: var(--border-strong);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.card-title {
    font-size: 12px;
    font-weight: bold;
    line-height: 1.3;
    margin: 0;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 11px;
}

.badge {
    padding: 2px 6px;
    border-radius: 2px;
    background: rgba(0,0,0,0.03);
    border: 1px solid var(--border);
    font-size: 10px;
    color: var(--text-muted);
}
[data-theme="dark"] .badge {
    background: rgba(255,255,255,0.03);
}

.badge--accent {
    border-color: var(--border-strong);
    color: var(--text);
    font-weight: bold;
}

.card-md5 {
    font-family: monospace;
    font-size: 10px;
    padding: 3px 6px;
    border-radius: 2px;
    background: rgba(0,0,0,0.02);
    border: 1px dashed var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
}
[data-theme="dark"] .card-md5 {
    background: rgba(255,255,255,0.02);
}

.card-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.card-actions .btn {
    flex: 1;
    justify-content: center;
}

/* --- MAGNETS TAB --- */
.magnet-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: var(--shadow);
}

.magnet-row {
    border-radius: 3px;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.magnet-row:hover {
    border-color: var(--border-strong);
}

.magnet-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.copied-feedback {
    color: var(--accent);
    font-size: 11px;
    font-weight: bold;
}

/* --- MIRRORS --- */
.mirrors-section {
    border: 1px solid var(--border);
    background: var(--bg-surface);
    border-radius: 4px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow);
}

.mirrors-title {
    font-size: 16px;
    font-weight: bold;
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
}

.mirror-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 12px;
    background: var(--bg);
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-label {
    font-size: 11px;
    font-weight: bold;
    color: var(--text-muted);
}

.form-input, .form-select {
    padding: 6px 8px;
    border-radius: 3px;
    border: 1px solid var(--border-strong);
    background: var(--bg-surface);
    color: var(--text);
}
.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--text);
}

.form-error {
    font-size: 11px;
    color: #b00;
    font-weight: bold;
}

.mirror-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mirror-item {
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg);
}

.mirror-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mirror-name { font-weight: bold; font-size: 13px; }
.mirror-url { font-size: 11px; color: var(--text-muted); }
.mirror-cat { font-size: 10px; font-weight: bold; text-transform: uppercase; color: var(--text-dim); }

.mirror-votes {
    display: flex;
    align-items: center;
    gap: 6px;
}

.vote-btn {
    padding: 4px 8px;
    font-size: 11px;
    font-weight: bold;
}

.vote-score {
    font-weight: bold;
    font-size: 13px;
    min-width: 20px;
    text-align: center;
}

/* --- FILTERS SIDEBAR --- */
.layout-with-filters {
    display: flex;
    gap: 14px;
    width: 100%;
}

.filters-panel {
    width: 240px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    border-radius: 4px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    box-shadow: var(--shadow);
}

.filters-panel.collapsed { display: none; }

.filters-toggle {
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    color: var(--text-muted);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px dashed var(--border);
    padding-top: 8px;
}

.filter-label {
    font-size: 11px;
    font-weight: bold;
    color: var(--text-muted);
}

.filter-range {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-range input[type="number"] {
    width: 70px;
    padding: 4px;
    border-radius: 3px;
    border: 1px solid var(--border-strong);
    background: var(--bg);
    color: var(--text);
    font-size: 11px;
}

.filter-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.filter-check {
    padding: 3px 6px;
    border-radius: 3px;
    border: 1px solid var(--border);
    background: var(--bg);
    font-size: 10px;
    cursor: pointer;
    font-weight: bold;
    color: var(--text-muted);
    transition: all 0.1s ease;
}

.filter-check:hover {
    border-color: var(--border-strong);
}

.filter-check.selected {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}

.filter-select {
    padding: 4px 6px;
    font-size: 11px;
}

.results-main { flex: 1; min-width: 0; }

/* --- SPEED TEST --- */
.speedtest-section {
    border: 1px solid var(--border);
    background: var(--bg-surface);
    border-radius: 4px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow);
}

.speedtest-table {
    width: 100%;
    border-collapse: collapse;
}

.speedtest-table th, .speedtest-table td {
    border: 1px solid var(--border);
    padding: 8px 10px;
    text-align: left;
    font-size: 12px;
}

.speedtest-table th {
    background: var(--bg-elevated);
    font-weight: bold;
}

.speedtest-table .fastest {
    background: rgba(0,255,0,0.08);
    font-weight: bold;
}
[data-theme="dark"] .speedtest-table .fastest {
    background: rgba(0,255,0,0.12);
}

/* --- SKELETON SCREEN --- */
.skel {
    border: 1px dashed var(--border);
    background: var(--bg-surface);
    border-radius: 3px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.skel-line {
    height: 12px;
    background: rgba(0,0,0,0.05);
    border-radius: 2px;
    animation: skel-pulse 1s infinite alternate;
}
[data-theme="dark"] .skel-line {
    background: rgba(255,255,255,0.05);
}

.skel-w90 { width: 90%; }
.skel-w50 { width: 50%; }
.skel-w40 { width: 40%; }
.skel-h24 { height: 24px; }

@keyframes skel-pulse {
    from { opacity: 0.4; }
    to { opacity: 1; }
}

/* --- EMPTY / ERROR --- */
.empty, .error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px;
    color: var(--text-dim);
}

.empty-icon { font-size: 24px; }
.empty-msg { font-size: 12px; font-weight: bold; }

/* --- TOAST --- */
.toast-wrap {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 1000;
}

.toast {
    padding: 10px 16px;
    border-radius: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    color: var(--text);
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateX(120%);
    transition: transform 0.2s ease;
}

.toast.show { transform: translateX(0); }
.toast--ok { border-left: 4px solid var(--text); }
.toast--err { border-left: 4px solid #b00; }

/* --- FOOTER --- */
.ftr {
    margin-top: auto;
    padding: 20px 0 10px 0;
    border-top: 1px solid var(--border);
    width: 100%;
    text-align: center;
    font-size: 11px;
    font-weight: bold;
    color: var(--text-dim);
}

/* --- RESPONSIVE --- */
@media (max-width: 1024px) {
    .results { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .app { padding: 10px; }
    .results, .results--single { grid-template-columns: 1fr; }
    .layout-with-filters { flex-direction: column; }
    .filters-panel {
        width: 100%;
        position: static;
        max-height: none;
    }
    .form-row { flex-direction: column; }
    .hdr { flex-direction: column; gap: 10px; align-items: flex-start; }
    .hdr-actions { width: 100%; justify-content: flex-end; }
}

.sources-status-wrap {
    display: flex;
    gap: 12px;
    padding: 8px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-top: 8px;
    width: 100%;
    max-width: 600px;
    justify-content: space-around;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
    font-size: 11px;
    font-weight: bold;
    flex-wrap: wrap;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-dim);
}

.status-indicator.pending {
    color: var(--text-muted);
    animation: skel-pulse 0.8s infinite alternate;
}

.status-indicator.ok {
    color: #2b8a3e;
}
[data-theme="dark"] .status-indicator.ok {
    color: #40c057;
}

.status-indicator.error {
    color: #c92a2a;
}
[data-theme="dark"] .status-indicator.error {
    color: #fa5252;
}

.status-indicator.empty {
    color: var(--text-dim);
    opacity: 0.6;
}

.hidden { display: none !important; }