/* ============================================================
   Qtrx Localization Verification — Stylesheet
   Quanterix branding: Navy #003041, Slate #395E77, Blue #0864B0,
   Green #D3D655, Grey #636569
   ============================================================ */

:root {
    --navy: #003041;
    --slate: #395E77;
    --blue: #0864B0;
    --green: #D3D655;
    --grey: #636569;
    --light-grey: #BBB8B8;

    --bg-primary: #0f1117;
    --bg-secondary: #1a1b23;
    --bg-tertiary: #22232d;
    --bg-panel: #1e1f29;
    --bg-hover: #2a2b37;
    --bg-input: #16171f;

    --text-primary: #e8e8ee;
    --text-secondary: #a0a0b0;
    --text-tertiary: #6a6a7a;
    --text-inverse: #0f1117;

    --border: #2d2e3a;
    --border-light: #3a3b4a;

    --accent-green: #4ade80;
    --accent-red: #f87171;
    --accent-yellow: #fbbf24;
    --accent-blue: #60a5fa;

    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;

    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.4);
}

html.light {
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f0f2;
    --bg-panel: #ffffff;
    --bg-hover: #f0f0f5;
    --bg-input: #f8f8fa;

    --text-primary: #1a1a2e;
    --text-secondary: #555570;
    --text-tertiary: #8888a0;
    --text-inverse: #ffffff;

    --border: #e0e0e8;
    --border-light: #d0d0d8;

    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.12);
}

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

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

.mono { font-family: 'Roboto Mono', 'Consolas', monospace; font-size: 0.85em; }

/* ---- Header ---- */
#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 52px;
    background: var(--navy);
    border-bottom: 2px solid var(--blue);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    background: var(--blue);
    color: white;
    font-weight: 700;
    font-size: 14px;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    letter-spacing: 0.5px;
}

#header h1 {
    color: white;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: all 0.15s;
}
.icon-btn:hover { color: white; background: rgba(255,255,255,0.1); }

/* ---- Status Badges ---- */
.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}
.status-badge.connected { background: rgba(74,222,128,0.15); color: var(--accent-green); }
.status-badge.disconnected { background: rgba(248,113,113,0.15); color: var(--accent-red); }
.status-badge.connecting { background: rgba(251,191,36,0.15); color: var(--accent-yellow); }
.status-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
}
.status-badge.connecting .status-dot { animation: pulse 1.2s infinite; }

.lang-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: rgba(8,100,176,0.2);
    color: var(--accent-blue);
}

/* ---- Screens ---- */
.screen { padding: 24px; }

/* ---- Setup Screen ---- */
.setup-card {
    max-width: 560px;
    margin: 60px auto;
    text-align: center;
}

.setup-icon { margin-bottom: 20px; }

.setup-card h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
}

.setup-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

.setup-steps {
    text-align: left;
    margin-bottom: 24px;
}

.setup-step {
    display: flex;
    gap: 16px;
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    transition: background 0.15s;
}
.setup-step:hover { background: var(--bg-hover); }

.step-number {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.step-content strong {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
}

.step-content p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 8px;
}

.step-content code {
    background: var(--bg-tertiary);
    padding: 1px 6px;
    border-radius: 3px;
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
}

.setup-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.setup-status.status-idle {
    background: rgba(248,113,113,0.06);
    border: 1px solid rgba(248,113,113,0.15);
}

.status-icon-off { color: var(--accent-red); font-size: 16px; }
.status-icon-on { color: var(--accent-green); font-size: 16px; }

.setup-alt {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 12px;
}

.setup-alt-text {
    color: var(--text-tertiary);
    font-size: 12px;
}

/* ---- Spinner ---- */
.spinner {
    width: 18px; height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-light); }

.btn-primary {
    background: var(--blue);
    border-color: var(--blue);
    color: white;
}
.btn-primary:hover { background: #0970c4; }

.btn-secondary {
    background: transparent;
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ---- Dashboard Grid ---- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    max-width: 1400px;
    margin: 0 auto;
}

@media (max-width: 1024px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}

/* ---- Panels ---- */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.panel-header h3 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.panel-body { padding: 16px; }

.panel-warning {
    border-color: var(--accent-yellow);
}
.panel-warning .panel-header {
    background: rgba(251,191,36,0.08);
}

/* ---- DB Stats ---- */
.db-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.stat {
    text-align: center;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.stat-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-blue);
}

.stat-label {
    display: block;
    font-size: 10px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* ---- Regeneration Progress ---- */
.regen-progress {
    padding: 0 16px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--blue);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s;
}

#regenText { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }

/* ---- Element Inspector ---- */
.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-tertiary);
}
.empty-state.small { padding: 16px; }
.empty-state p { font-size: 13px; margin-top: 8px; }

.element-info { display: flex; flex-direction: column; gap: 6px; }

.element-row {
    display: flex;
    gap: 8px;
    align-items: baseline;
}

.element-row label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-tertiary);
    min-width: 50px;
    flex-shrink: 0;
}

.element-row span { font-size: 13px; word-break: break-all; }

.element-text {
    font-weight: 600;
    color: var(--accent-blue);
    font-size: 15px !important;
}

.inspect-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}
.inspect-badge.idle { background: var(--bg-tertiary); color: var(--text-tertiary); }
.inspect-badge.inspecting { background: rgba(74,222,128,0.15); color: var(--accent-green); }
.inspect-badge.captured { background: rgba(251,191,36,0.15); color: var(--accent-yellow); }

/* ---- Hierarchy Tree ---- */
.hierarchy-section {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.hierarchy-section h4 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}

.hierarchy-tree {
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    line-height: 1.8;
    color: var(--text-secondary);
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow-x: auto;
}

.hier-node { display: block; white-space: nowrap; }
.hier-indent { color: var(--border-light); }
.hier-type { color: var(--blue); font-weight: 500; }
.hier-id { color: var(--green); }
.hier-name { color: var(--text-tertiary); font-style: italic; }
.hier-current { background: rgba(8,100,176,0.15); border-radius: 2px; padding: 0 4px; }

/* ---- Translation Result ---- */
.translation-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.translation-row label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-tertiary);
    min-width: 30px;
}

.match-badge {
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 10px;
    font-weight: 700;
}
.match-badge.match { background: rgba(74,222,128,0.15); color: var(--accent-green); }
.match-badge.mismatch { background: rgba(248,113,113,0.15); color: var(--accent-red); }
.match-badge.not-found { background: rgba(251,191,36,0.15); color: var(--accent-yellow); }

.match-type-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
}

.translation-compare {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.compare-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
}

.compare-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-tertiary);
    min-width: 100px;
    flex-shrink: 0;
}

.compare-value {
    font-size: 14px;
    word-break: break-word;
}

.compare-row.actual .compare-value { font-weight: 600; }
.compare-row.actual.match-yes { border-left: 3px solid var(--accent-green); }
.compare-row.actual.match-no { border-left: 3px solid var(--accent-red); }

.translation-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
    color: var(--text-tertiary);
}

/* ---- All Translations Grid ---- */
.all-translations {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.all-translations h4 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}

.translations-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.trans-cell {
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 12px;
    overflow: hidden;
}

.trans-lang {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 2px;
}

.trans-value {
    color: var(--text-primary);
    word-break: break-word;
}

.trans-cell.active {
    border: 1px solid var(--blue);
    background: rgba(8,100,176,0.1);
}

/* ---- Search ---- */
.search-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.search-bar input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}
.search-bar input:focus { border-color: var(--blue); }

.search-filters {
    margin-bottom: 10px;
}

.search-filters select {
    padding: 4px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 12px;
    font-family: inherit;
    outline: none;
}

.search-results {
    max-height: 400px;
    overflow-y: auto;
}

.search-result-item {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.1s;
}
.search-result-item:hover { background: var(--bg-hover); }

.search-result-key {
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    color: var(--accent-blue);
    font-weight: 500;
}

.search-result-value {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result-meta {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.search-count {
    font-size: 11px;
    color: var(--text-tertiary);
    padding: 4px 0 8px;
}

/* ---- History Table ---- */
.history-table {
    max-height: 350px;
    overflow-y: auto;
}

.history-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.history-table th {
    text-align: left;
    padding: 6px 8px;
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
}

.history-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.history-table tr:hover td { background: var(--bg-hover); }

.history-match { color: var(--accent-green); font-weight: 600; }
.history-mismatch { color: var(--accent-red); font-weight: 600; }
.history-notfound { color: var(--accent-yellow); font-weight: 600; }

/* ---- Toast Notifications ---- */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
}

.toast {
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    min-width: 280px;
    max-width: 400px;
}

.toast-info { background: var(--navy); color: white; border-left: 4px solid var(--blue); }
.toast-success { background: #0a2e1a; color: var(--accent-green); border-left: 4px solid var(--accent-green); }
.toast-warning { background: #2e2a0a; color: var(--accent-yellow); border-left: 4px solid var(--accent-yellow); }
.toast-error { background: #2e0a0a; color: var(--accent-red); border-left: 4px solid var(--accent-red); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }
