/* Shop-Bildverwaltung — ein Stylesheet, handgeschrieben, nüchtern. */

:root {
    --bg: #f2f3f5;
    --surface: #fff;
    --border: #dcdfe4;
    --text: #1e2126;
    --muted: #6b7280;
    --danger: #b3261e;
    --danger-bg: #fdecea;
    --success: #1e7a3c;
    --success-bg: #e8f5ec;
    --radius: 6px;
    --brand: #444;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: #1f4f82; }
h1 { font-size: 20px; margin: 0 0 16px; }
code { background: #eceef1; padding: 1px 4px; border-radius: 3px; font-size: 13px; }

/* --- Kopfbereich --- */

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }

.topbar__inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
}

.topbar__brand { display: flex; align-items: center; text-decoration: none; color: var(--text); }
.topbar__logo { height: 52px; width: auto; display: block; }
.topbar__user { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 14px; }
.topbar__name { color: var(--muted); text-decoration: none; border-bottom: 1px dotted currentColor; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; }

.tab {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    background: var(--surface);
}

.tab--active { background: var(--tab-color); border-color: var(--tab-color); color: #fff; }

.page { max-width: 1100px; margin: 0 auto; padding: 20px 16px 64px; }

/* --- Meldungen --- */

.flash { padding: 10px 14px; border-radius: var(--radius); margin: 0 0 14px; border: 1px solid transparent; }
.flash--error { background: var(--danger-bg); border-color: #f2c4c0; color: var(--danger); }
.flash--success { background: var(--success-bg); border-color: #bfe0c9; color: var(--success); }
.flash ul { margin: 6px 0 0 18px; padding: 0; }

/* --- Werkzeugleiste --- */

.toolbar { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin-bottom: 16px; }
.stats { margin: 0; color: var(--muted); }
.stats__missing { color: var(--danger); text-decoration: none; border-bottom: 1px dotted currentColor; }
.stats__missing.is-zero { color: var(--muted); }
.toolbar__controls { margin-left: auto; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.search {
    min-height: 40px;
    min-width: 220px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font: inherit;
}

.sync { display: flex; align-items: center; gap: 8px; }
.sync--block { margin: 0 0 14px; flex-wrap: wrap; }
.sync__info { color: var(--muted); font-size: 13px; }
.sync__info--error { color: var(--danger); }
.sync.is-busy .button { opacity: .6; pointer-events: none; }

.chips, .subtabs { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
}

.chip--active { background: var(--text); border-color: var(--text); color: #fff; }

/* --- Gruppen --- */

.group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; }
.group[hidden] { display: none; }

.group__head {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 0 14px;
    cursor: pointer;
    list-style: none;
    font-weight: 600;
    border-bottom: 1px solid transparent;
}

.group[open] .group__head { border-bottom-color: var(--border); }
.group__head::-webkit-details-marker { display: none; }
.group__head::before { content: "▸"; color: var(--muted); font-size: 12px; }
.group[open] .group__head::before { content: "▾"; }
.group__name { color: var(--brand); }
.group__count { font-weight: 400; color: var(--muted); font-size: 14px; }

.group__export {
    margin-left: auto;
    padding: 0 10px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--muted);
    font-size: 15px;
}

.group__export:hover { color: var(--text); border-color: #b9bec6; }

.badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.badge--missing { background: var(--danger-bg); color: var(--danger); }
.badge--replace { background: #fff3e0; color: #8a5a2b; }
.badge--count { background: var(--brand); color: #fff; }

/* --- Import --- */

.import { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 8px; }
.import th, .import td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #eef0f2; }
.import th { color: var(--muted); font-weight: 600; }
.import__title { font-size: 16px; margin: 22px 0 8px; }
.import__meta { color: var(--muted); white-space: nowrap; }
.import__row--error td { color: var(--danger); }
.import__missing { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.flash--info { background: #eef2f7; border-color: #d3dce8; color: #38506b; }

/* --- Variantenzeile --- */

.row {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    align-items: center;
    gap: 14px;
    padding: 8px 14px;
    border-top: 1px solid #eef0f2;
    border-left: 3px solid transparent;
}

.row:first-of-type { border-top: 0; }
.row--missing { border-left-color: #e7a9a4; background: #fffafa; }
.row[hidden] { display: none; }
.row.is-dragover { background: #eef5ff; border-left-color: #1f4f82; }
.row.is-updated { animation: blink 1.1s ease-out; }

@keyframes blink { from { background: #d9f2e1; } to { background: transparent; } }

.thumb { width: 64px; height: 64px; object-fit: contain; background: #f7f8f9; border: 1px solid var(--border); border-radius: 4px; cursor: zoom-in; }
.thumb--empty { cursor: default; opacity: .6; }

.row__info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row__sku { font-weight: 600; font-variant-numeric: tabular-nums; }
.row__meta { color: var(--muted); font-size: 13px; }
.row__status { font-size: 13px; min-height: 0; }
.row__status--error { color: var(--danger); }
.hint { color: var(--muted); font-size: 13px; }
.row__meta .hint { margin-left: 6px; font-style: italic; }

.row__actions { display: flex; align-items: center; gap: 8px; }
.upload { display: flex; align-items: center; gap: 8px; }
.upload__file { max-width: 190px; font-size: 13px; }
.js .upload__file { display: none; }
.upload.is-busy .button { opacity: .6; pointer-events: none; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.button:hover { border-color: #b9bec6; }
.button--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.linkbutton { background: none; border: 0; padding: 0; font: inherit; color: #1f4f82; cursor: pointer; text-decoration: underline; }
.linkbutton--danger { color: var(--danger); }

.spinner {
    width: 14px; height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;
    display: inline-block;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Menü --- */

.menu { position: relative; }
.menu__toggle { list-style: none; min-width: 40px; min-height: 40px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; background: var(--surface); }
.menu__toggle::-webkit-details-marker { display: none; }

.menu__panel {
    position: absolute;
    right: 0;
    top: 44px;
    z-index: 20;
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
    padding: 4px;
}

.menu__item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: 0;
    background: none;
    font: inherit;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    border-radius: 4px;
}

.menu__item:hover { background: #f2f3f5; }
.menu__item--danger { color: var(--danger); }

/* --- Verwaiste Bilder --- */

.orphans { margin-top: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.orphans summary { cursor: pointer; font-weight: 600; }
.orphans__list { list-style: none; margin: 12px 0 0; padding: 0; }
.orphans__item { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid #eef0f2; }

/* --- Karten und Formulare --- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card--login { max-width: 380px; margin: 40px auto; }
.form { display: flex; flex-direction: column; gap: 8px; }
.form label { font-size: 14px; color: var(--muted); }
.form input[type="text"], .form input[type="password"] { min-height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius); font: inherit; }
.form__actions { display: flex; gap: 10px; margin-top: 12px; }

.listeditor {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: 14px/1.5 ui-monospace, Consolas, "Courier New", monospace;
    resize: vertical;
}

/* --- Lightbox und Modal --- */

.lightbox, .modal { position: fixed; inset: 0; background: rgba(20, 22, 26, .8); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.lightbox[hidden], .modal[hidden] { display: none; }
.lightbox img { max-width: 92vw; max-height: 88vh; background: #fff; border-radius: 4px; }
.lightbox__close, .modal__close { position: absolute; top: 12px; right: 16px; font-size: 28px; line-height: 1; background: none; border: 0; color: #fff; cursor: pointer; }
.modal__box { background: var(--surface); border-radius: var(--radius); width: min(560px, 100%); max-height: 80vh; overflow: auto; }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal__head h2 { font-size: 16px; margin: 0; }
.modal__close { position: static; color: var(--text); font-size: 24px; }
.modal__body { padding: 8px 16px 16px; }
.modal__body table { width: 100%; border-collapse: collapse; font-size: 14px; }
.modal__body th, .modal__body td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #eef0f2; }

/* --- Klein --- */

@media (max-width: 700px) {
    .row { grid-template-columns: 64px 1fr; }
    .row__actions { grid-column: 2; justify-content: flex-start; flex-wrap: wrap; }
    .toolbar__controls { margin-left: 0; width: 100%; }
    .search { flex: 1 1 100%; }
    .topbar__user { width: 100%; margin-left: 0; }
    .topbar__logo { height: 40px; }
    .tabs { width: 100%; }
}
