/* Kartenscanner – Gompper Webdesign */

:root {
    --bg: #0f1216;
    --surface: #161a20;
    --surface-2: #1c212a;
    --line: #272d36;
    --line-soft: #1f242c;
    --text: #e8ebf0;
    --muted: #8a93a3;
    --accent: #e0b357;
    --accent-dim: #8a6c2e;
    --ok: #63d29b;
    --err: #ff8177;
    --radius: 10px;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    padding-bottom: env(safe-area-inset-bottom);
}

h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

button, input, select { font: inherit; color: inherit; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color .15s ease, background .15s ease, opacity .15s ease;
}

.btn:hover:not(:disabled) { border-color: var(--accent-dim); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #1a1408;
    font-weight: 600;
}
.btn-primary:hover { background: #ecc370; border-color: #ecc370; }

.btn-ghost { background: transparent; }

/* ---------- Topbar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
    background: rgba(15, 18, 22, .88);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line-soft);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
    width: 26px; height: 18px;
    border: 2px solid var(--accent);
    border-radius: 3px;
    position: relative;
}
.brand-mark::after {
    content: "";
    position: absolute;
    left: 3px; top: 4px;
    width: 10px; height: 2px;
    background: var(--accent);
    box-shadow: 0 4px 0 var(--accent-dim);
}
.brand-name { font-weight: 600; letter-spacing: -0.01em; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions .btn { padding: 7px 13px; font-size: 14px; }

.counter {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--muted);
    margin-right: 4px;
}

/* ---------- Layout ---------- */

.wrap { max-width: 940px; margin: 0 auto; padding: 26px 20px 80px; }

.section-label {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 12px;
}

/* ---------- Intake ---------- */

.intake {
    border: 1px dashed var(--line);
    border-radius: 14px;
    background:
        radial-gradient(120% 80% at 50% 0%, rgba(224, 179, 87, .06), transparent 60%),
        var(--surface);
    padding: 34px 24px;
    text-align: center;
    transition: border-color .15s ease, background .15s ease;
}
.intake.dragover { border-color: var(--accent); background: var(--surface-2); }

.intake-title { font-size: 22px; }
.intake-text { color: var(--muted); margin: 8px auto 20px; max-width: 46ch; }
.intake-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.switch {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-top: 20px;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
}
.switch input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- Einstellungen ---------- */

.settings {
    margin-top: 16px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
}
.settings summary {
    cursor: pointer;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted);
}
.settings summary:hover { color: var(--text); }
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px 16px;
    margin-top: 16px;
}
.settings-hint { font-size: 13px; color: var(--muted); margin: 14px 0 0; }

/* ---------- Queue ---------- */

.queue { margin-top: 28px; }
.queue-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.queue-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    font-size: 14px;
}
.queue-item .q-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.queue-item .q-state { font-family: var(--mono); font-size: 12px; letter-spacing: .06em; }
.queue-item[data-state="wartet"] .q-state { color: var(--muted); }
.queue-item[data-state="liest"] .q-state { color: var(--accent); }
.queue-item[data-state="fehler"] .q-state { color: var(--err); }
.queue-item .q-retry {
    background: none;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 4px 9px;
    font-size: 12px;
    cursor: pointer;
}

.spinner {
    width: 14px; height: 14px;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Ergebnisse ---------- */

.results { margin-top: 32px; }

.empty {
    text-align: center;
    color: var(--muted);
    padding: 40px 20px;
    font-size: 14px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 16px;
}

.card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }

.thumb-wrap {
    flex: none;
    width: 84px; height: 52px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--bg);
    transform: rotate(-1.5deg);
    box-shadow: 0 6px 16px rgba(0, 0, 0, .45);
}
.thumb { width: 100%; height: 100%; object-fit: cover; display: block; }

.card-title { flex: 1; min-width: 0; }
.card-name { display: block; font-size: 16px; }
.card-company { display: block; font-size: 13px; color: var(--muted); }

.card-tools { display: flex; gap: 6px; }
.icon-btn {
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 6px 10px;
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent-dim); }
.js-remove:hover { color: var(--err); border-color: var(--err); }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px 16px;
}

.cell { display: flex; flex-direction: column; }
.cell.wide { grid-column: 1 / -1; }

.cell label {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 5px;
}
.cell input {
    background: var(--bg);
    border: 1px solid transparent;
    border-bottom: 1px solid var(--line);
    border-radius: 6px 6px 0 0;
    padding: 8px 10px;
    width: 100%;
}
.cell input:hover { border-bottom-color: var(--accent-dim); }
.cell input:focus { outline: none; border-bottom-color: var(--accent); background: var(--surface-2); }
.cell input::placeholder { color: #4a525f; }

/* ---------- Toast ---------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    padding: 11px 16px;
    font-size: 14px;
    max-width: min(520px, calc(100vw - 32px));
    box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
    z-index: 40;
}
.toast[data-kind="fehler"] { border-left-color: var(--err); }
.toast[data-kind="ok"] { border-left-color: var(--ok); }


/* ---------- Aktionsleiste je Karte ---------- */

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}
.card-actions .icon-btn { padding: 7px 12px; font-size: 13px; }
.card-actions .js-trello { color: var(--text); border-color: var(--accent-dim); }
.card-actions .js-trello:hover { background: var(--surface-2); border-color: var(--accent); }

/* ---------- Ladeanzeige der Texterkennung ---------- */

.engine {
    margin-top: 20px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
}
.engine-row { display: flex; align-items: center; gap: 10px; font-size: 14px; margin-bottom: 10px; }
.bar { height: 3px; background: var(--line-soft); border-radius: 2px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }

/* ---------- Unsichere Felder und Rohtext ---------- */

.cell input.unsicher {
    border-bottom-color: var(--accent);
    background: rgba(224, 179, 87, .06);
}

.raw { margin-top: 14px; border-top: 1px solid var(--line-soft); padding-top: 10px; }
.raw summary {
    cursor: pointer;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
}
.raw summary:hover { color: var(--text); }
.raw-text {
    margin: 10px 0 0;
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.6;
    color: var(--muted);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.icon-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ---------- Mobil ---------- */

@media (max-width: 640px) {
    .topbar { flex-wrap: wrap; padding: 10px 14px; }
    .brand-name { font-size: 15px; }
    .wrap { padding: 18px 14px 60px; }
    .intake { padding: 26px 16px; }
    .intake-buttons .btn { flex: 1 1 140px; }
    .card-tools { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
