/* ═══════════════════════════════════════════════════════════════════════════
   Auto Find New Offset — Dark Theme Stylesheet
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --bg:           #0d1117;
    --bg-card:      #161b22;
    --bg-input:     #1c2333;
    --bg-hover:     #21262d;
    --border:       #30363d;
    --border-focus: #58a6ff;
    --text:         #e6edf3;
    --text-sec:     #8b949e;
    --text-dim:     #484f58;
    --accent:       #58a6ff;
    --green:        #3fb950;
    --red:          #f85149;
    --orange:       #d29922;
    --purple:       #bc8cff;
    --btn-ok:       #238636;
    --btn-ok-h:     #2ea043;
    --btn-danger:   #da3633;
    --radius:       8px;
    --radius-sm:    6px;
    --font:         'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono:         'JetBrains Mono', 'Cascadia Code', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--mono); font-size: 0.92em; }
.text-dim { color: var(--text-dim); }
.text-sec { color: var(--text-sec); }
.text-accent { color: var(--accent); }
.hidden { display: none !important; }

/* ── NAVBAR ─────────────────────────────────────────────────────────────── */
.navbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.8rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand { display: flex; align-items: center; gap: 0.6rem; }
.brand-icon { font-size: 1.6rem; }
.brand-title { font-size: 1rem; font-weight: 700; }
.brand-sub { font-size: 0.72rem; color: var(--text-sec); }
.nav-links { display: flex; gap: 0.25rem; margin-left: auto; }
.nav-link {
    display: flex; align-items: center; gap: 0.35rem;
    padding: 0.4rem 0.8rem; border-radius: var(--radius-sm);
    color: var(--text-sec); font-size: 0.88rem; font-weight: 500;
    transition: all 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--bg-hover); text-decoration: none; }
.nav-link.active { color: var(--accent); background: rgba(88,166,255,0.1); }
.nav-right { display: flex; align-items: center; gap: 0.8rem; margin-left: 1rem; }
.nav-user { color: var(--text-sec); font-size: 0.85rem; }
.nav-logout { color: var(--red) !important; }
.nav-logout:hover { background: rgba(248,81,73,0.1) !important; }

/* ── MAIN ───────────────────────────────────────────────────────────────── */
.main-content { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
.page-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.2rem; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; }

/* ── CARDS ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.4rem;
    margin-bottom: 1rem;
}
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }

/* ── FILE DROP ─────────────────────────────────────────────────────────── */
.file-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.file-label { display: flex; align-items: center; gap: 0.4rem; font-weight: 500; margin-bottom: 0.4rem; color: var(--text-sec); font-size: 0.88rem; }
.file-drop {
    display: flex; align-items: center; justify-content: center;
    height: 48px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    padding: 0 1rem;
}
.file-drop:hover, .file-drop.drag-over {
    border-color: var(--accent);
    background: rgba(88,166,255,0.05);
}
.file-drop.has-file { border-style: solid; border-color: var(--green); }
.file-drop-text {
    font-size: 0.85rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-drop.has-file .file-drop-text { color: var(--green); font-family: var(--mono); }

/* ── OFFSET INPUT ──────────────────────────────────────────────────────── */
.offset-section { display: grid; grid-template-columns: 1fr 260px; gap: 1rem; }
.offset-input-area textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.9rem;
    padding: 0.8rem;
    resize: vertical;
    min-height: 180px;
    transition: border-color 0.2s;
}
.offset-input-area textarea:focus { outline: none; border-color: var(--border-focus); }
.offset-input-area textarea::placeholder { color: var(--text-dim); }

.settings-panel {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex; flex-direction: column; gap: 0.6rem;
}
.settings-title { font-weight: 600; display: flex; align-items: center; gap: 0.3rem; }
.setting-label { font-size: 0.82rem; color: var(--text-sec); }
.setting-select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 0.5rem;
    font-size: 0.9rem;
}
.setting-select:focus { outline: none; border-color: var(--border-focus); }

/* ── BUTTONS ───────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem;
    border: none; border-radius: var(--radius-sm); cursor: pointer;
    font-family: var(--font); font-weight: 600; font-size: 0.88rem;
    padding: 0.55rem 1.2rem;
    transition: all 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-full { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #4090e0; }
.btn-success { background: var(--btn-ok); color: #fff; }
.btn-success:hover { background: var(--btn-ok-h); }
.btn-secondary { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--btn-danger); color: #fff; }
.btn-danger:hover { background: #c22; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-xs { padding: 0.2rem 0.5rem; font-size: 0.75rem; }

/* ── PROGRESS ──────────────────────────────────────────────────────────── */
.progress-card { padding: 1rem 1.4rem; }
.progress-info { display: flex; justify-content: space-between; margin-bottom: 0.5rem; font-size: 0.88rem; }
.progress-bar-bg { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, #1f6feb, #58a6ff); border-radius: 3px; transition: width 0.3s; }
.progress-bar.upload-bar { background: linear-gradient(90deg, #238636, #3fb950); }
.progress-bar.upload-waiting {
    background: linear-gradient(90deg, #238636, #3fb950, #238636);
    background-size: 200% 100%;
    animation: uploadPulse 1.5s ease-in-out infinite;
}
@keyframes uploadPulse {
    0% { background-position: 0% 0%; opacity: 1; }
    50% { background-position: 100% 0%; opacity: 0.6; }
    100% { background-position: 0% 0%; opacity: 1; }
}

/* ── RESULTS TABLE ─────────────────────────────────────────────────────── */
.results-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.8rem; }
.results-header h2 { font-size: 1.15rem; }
.results-count { font-size: 0.85rem; color: var(--text-sec); }
.results-table-wrap { overflow-x: auto; }
.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.results-table th {
    padding: 0.6rem 0.8rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-sec);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.results-table td {
    padding: 0.55rem 0.8rem;
    border-bottom: 1px solid rgba(48,54,61,0.5);
    vertical-align: middle;
}
.results-table tbody tr:hover { background: var(--bg-hover); }
.results-table .col-idx { width: 40px; text-align: center; }
.results-table .col-type { width: 80px; }
.results-table .col-old, .results-table .col-new { width: 120px; }
.results-table .col-status { width: 110px; }
.results-table td.mono { font-family: var(--mono); font-size: 0.85rem; }
.results-table .row-ok td:first-child { border-left: 3px solid var(--green); }
.results-table .row-fail td:first-child { border-left: 3px solid var(--red); }
.results-table .compact { font-size: 0.82rem; }
.results-table .compact td, .results-table .compact th { padding: 0.4rem 0.6rem; }
.type-func { color: var(--purple); }
.type-var { color: var(--orange); }
.copyable { cursor: pointer; }
.copyable:hover { text-decoration: underline; }

/* ── ARCH BADGE ────────────────────────────────────────────────────────── */
.arch-badge {
    padding: 0.3rem 0.8rem; border-radius: var(--radius-sm);
    font-weight: 700; font-size: 0.82rem;
    background: rgba(88,166,255,0.15); color: var(--accent);
}

/* ── BADGES ────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block; padding: 0.15rem 0.5rem;
    border-radius: 999px; font-size: 0.75rem; font-weight: 600;
}
.badge-arch { background: rgba(88,166,255,0.15); color: var(--accent); }
.badge-found { background: rgba(63,185,80,0.15); color: var(--green); }
.badge-admin { background: rgba(188,140,255,0.15); color: var(--purple); }
.badge-user { background: rgba(139,148,158,0.15); color: var(--text-sec); }
.badge-active { background: rgba(63,185,80,0.15); color: var(--green); }
.badge-disabled { background: rgba(248,81,73,0.15); color: var(--red); }

/* ── HISTORY ───────────────────────────────────────────────────────────── */
.history-list { display: flex; flex-direction: column; gap: 0.5rem; }
.history-item {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 0.8rem 1rem;
    transition: background 0.15s;
}
.history-item:hover { background: var(--bg-hover); }
.history-main { display: flex; flex-direction: column; gap: 0.3rem; }
.history-files { display: flex; gap: 0.5rem; align-items: center; }
.history-meta { display: flex; gap: 0.6rem; align-items: center; }
.history-actions { display: flex; gap: 0.3rem; }

.empty-state { color: var(--text-sec); text-align: center; padding: 3rem; }

/* ── STATS GRID ────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.2rem; text-align: center;
}
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.82rem; color: var(--text-sec); margin-top: 0.3rem; }

/* ── FORMS ─────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: 0.3rem; font-size: 0.88rem; color: var(--text-sec); }
.form-group input, .form-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 0.6rem 0.8rem;
    font-family: var(--font);
    font-size: 0.9rem;
    transition: border-color 0.2s;
}
.form-group input:focus, .form-input:focus { outline: none; border-color: var(--border-focus); }
.form-group input::placeholder, .form-input::placeholder { color: var(--text-dim); }

.form-select {
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
    padding: 0.5rem; font-size: 0.9rem;
}

.inline-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.inline-form .form-input { width: auto; flex: 1; min-width: 140px; }
.form-msg { font-size: 0.85rem; margin-top: 0.5rem; padding: 0.4rem 0.8rem; border-radius: var(--radius-sm); }
.msg-ok { background: rgba(63,185,80,0.15); color: var(--green); }
.msg-err { background: rgba(248,81,73,0.15); color: var(--red); }

.action-cell { white-space: nowrap; display: flex; gap: 0.3rem; }

/* ── MODAL ─────────────────────────────────────────────────────────────── */
.modal {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.modal-content {
    position: relative; z-index: 1;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); width: 90%; max-width: 900px;
    max-height: 80vh; display: flex; flex-direction: column;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.2rem; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; }
.modal-close { background: none; border: none; color: var(--text-sec); font-size: 1.5rem; cursor: pointer; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.2rem; overflow-y: auto; }
.modal-meta { margin-bottom: 1rem; font-size: 0.85rem; color: var(--text-sec); }

/* ── LOGIN ─────────────────────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-container { width: 100%; max-width: 400px; padding: 1rem; }
.login-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 2rem; text-align: center;
}
.login-header { margin-bottom: 1.5rem; }
.login-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.login-header h1 { font-size: 1.4rem; }
.login-header p { font-size: 0.82rem; color: var(--text-sec); margin-top: 0.3rem; }
.login-form { text-align: left; }
.login-form .btn { margin-top: 0.5rem; }
.login-footer { margin-top: 1.5rem; font-size: 0.78rem; color: var(--text-dim); }

.alert { padding: 0.6rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: 0.88rem; }
.alert-error { background: rgba(248,81,73,0.12); color: var(--red); border: 1px solid rgba(248,81,73,0.3); }

/* ── CLEANUP / FILE MANAGER ─────────────────────────────────────────── */
.cleanup-actions { display: flex; flex-direction: column; gap: 0.75rem; }
.cleanup-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.8rem 1rem; background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-sm); gap: 1rem;
}
.cleanup-info { display: flex; flex-direction: column; gap: 0.15rem; }
.cleanup-info strong { font-size: 0.9rem; }
.cleanup-info .text-sec { font-size: 0.78rem; }
.cleanup-controls { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.file-filter-bar {
    display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.8rem;
}
.file-filter-bar .form-input { flex: 1; }

/* ── RESPONSIVE ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .file-grid { grid-template-columns: 1fr; }
    .offset-section { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .navbar { flex-wrap: wrap; gap: 0.5rem; }
    .nav-links { order: 3; width: 100%; }
}
