/* admin2/css/admin.css — Developnet product admin
   Colours follow the public site: blue #0066cc, orange #f2801f. */
:root {
    --blue: #0066cc;
    --blue-dark: #0052a3;
    --blue-soft: #e8f1fc;
    --orange: #f2801f;
    --orange-soft: #fdeedd;
    --green: #1a7f37;
    --green-soft: #e6f4ea;
    --red: #c62828;
    --red-soft: #fdecea;
    --ink: #1b2430;
    --ink-2: #4b5563;
    --ink-3: #6b7280;
    --ink-4: #9ca3af;
    --line: #e5e7eb;
    --line-2: #d1d5db;
    --bg: #f3f5f8;
    --card: #ffffff;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(17, 24, 39, .05), 0 1px 3px rgba(17, 24, 39, .08);
    --shadow-lg: 0 20px 50px rgba(17, 24, 39, .22);
    --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
}
[hidden] { display: none !important; }
a { color: var(--blue); }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
.muted { color: var(--ink-4); }
.lead { margin: 6px 0 0; color: var(--ink-2); max-width: 72ch; }
.inline { display: inline; }

/* ---------- Top bar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.topbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand img { height: 38px; width: auto; }
.brand span {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--ink-3);
    border-left: 1px solid var(--line-2);
    padding-left: 10px;
}
.topnav { display: flex; gap: 4px; margin-left: 8px; }
.topnav a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    text-decoration: none;
    color: var(--ink-2);
    font-weight: 600;
}
.topnav a:hover { background: var(--bg); color: var(--ink); }
.topnav a.active { background: var(--blue-soft); color: var(--blue); }
.topnav a .ext { font-size: 10px; opacity: .6; margin-left: -2px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-chip { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); padding: 0 6px; font-weight: 500; }

/* ---------- Page ---------- */
.page { max-width: 1280px; margin: 0 auto; padding: 24px 16px 80px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-head h1 { font-size: 28px; font-weight: 700; }
.back-link { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 600; margin-bottom: 14px; }
.back-link:hover { text-decoration: underline; }

/* ---------- Flash & toast ---------- */
.flash {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    border: 1px solid;
    font-weight: 500;
}
.flash-success { background: var(--green-soft); border-color: #b7e1c1; color: var(--green); }
.flash-error { background: var(--red-soft); border-color: #f5c2c0; color: var(--red); }
.flash i { font-size: 18px; }
.flash span { flex: 1; }
.flash-close { background: none; border: 0; font-size: 22px; line-height: 1; color: inherit; cursor: pointer; opacity: .6; }
.flash-close:hover { opacity: 1; }
.toast-root { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: var(--ink);
    color: #fff;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(8px);
    transition: .25s;
    max-width: 360px;
    font-weight: 500;
}
.toast.show { opacity: 1; transform: none; }
.toast-success i { color: #7ee2a8; }
.toast-error { background: var(--red); }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-label { display: block; font-size: 12px; color: var(--ink-3); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.stat-label i { color: var(--blue); margin-right: 4px; }
.stat-value { display: block; font-size: 28px; font-weight: 700; margin-top: 2px; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.search { position: relative; flex: 1 1 260px; }
.search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-4); pointer-events: none; }
.search input[type="search"] { padding-left: 36px; }
.toolbar select { flex: 0 1 auto; width: auto; min-width: 170px; }
.result-count { margin-left: auto; color: var(--ink-3); font-weight: 600; white-space: nowrap; }

/* ---------- Cards & tables ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.table-card { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 880px; }
.table th, .table td { padding: 12px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.table thead th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-3);
    background: #fafbfc;
}
.table .num { text-align: right; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn + .inline { margin-left: 4px; }
.table tbody tr.product-row:hover, .table tbody tr.area-row:hover { background: #f8fafc; }
.group-row th { background: var(--blue-soft); color: var(--blue-dark); font-weight: 700; font-size: 14px; padding: 10px 14px; }
.group-row th i { margin-right: 6px; }
.group-row .count { font-weight: 500; color: var(--ink-3); margin-left: 8px; font-size: 13px; }
.product-name { font-weight: 600; font-size: 15px; }
.cell-product .sub { color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-blue { background: var(--blue-soft); color: var(--blue-dark); }
.badge-orange { background: var(--orange-soft); color: #b35a00; }
.chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--green-soft);
    color: var(--green);
    font-size: 12.5px;
    font-weight: 600;
    margin: 2px 2px 2px 0;
}
.empty { text-align: center; padding: 48px 16px; color: var(--ink-3); }
.empty i { font-size: 32px; color: var(--ink-4); margin-bottom: 8px; display: block; }
.empty p { margin: 0 0 12px; font-size: 16px; }

/* ---------- Click-to-edit price ---------- */
.price-edit {
    font: inherit;
    display: inline-flex;
    align-items: baseline;
    gap: 2px;
    border: 1px dashed transparent;
    background: none;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--ink);
}
.price-edit .cur { font-size: 13px; color: var(--ink-3); margin-right: 2px; }
.price-edit .amount { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.price-edit .per { font-size: 12px; color: var(--ink-3); }
.price-edit i { font-size: 11px; color: var(--ink-4); margin-left: 6px; opacity: .55; transition: opacity .15s; }
.price-edit:hover, .price-edit:focus-visible { border-color: var(--blue); background: var(--blue-soft); outline: none; }
.price-edit:hover i, .price-edit:focus-visible i { opacity: 1; color: var(--blue); }
.price-form { display: inline-flex; align-items: center; gap: 6px; }
.price-form .cur { color: var(--ink-3); font-weight: 600; }
.price-form input { width: 120px; padding: 6px 8px; font-weight: 700; font-size: 15px; }
.price-form.saving { opacity: .6; pointer-events: none; }
@keyframes saved-flash { from { background: #c8f0d3; } to { background: transparent; } }
.cell-price.just-saved { animation: saved-flash 1.6s ease-out; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
    line-height: 1.2;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary { background: var(--card); color: var(--ink); border-color: var(--line-2); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-danger-ghost { background: transparent; color: var(--red); }
.btn-danger-ghost:hover { background: var(--red-soft); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-block { width: 100%; }
.icon-btn { background: none; border: 0; font-size: 26px; line-height: 1; color: var(--ink-3); cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm); }
.icon-btn:hover { background: var(--bg); color: var(--ink); }

/* ---------- Forms ---------- */
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
    width: 100%;
    font: inherit;
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 102, 204, .18); }
select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.span-2 { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: 14px; }
.field.required label::after { content: " *"; color: var(--red); }
.help { margin: 0; font-size: 13px; color: var(--ink-3); }
.input-prefix { display: flex; align-items: stretch; }
.input-prefix span {
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: var(--bg);
    border: 1px solid var(--line-2);
    border-right: 0;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    font-weight: 700;
    color: var(--ink-2);
}
.input-prefix input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.internal-details { margin-top: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: #fafbfc; }
.internal-details summary { cursor: pointer; padding: 12px 16px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
.internal-details summary::-webkit-details-marker { display: none; }
.internal-details summary::before {
    content: "\f054";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 11px;
    color: var(--ink-4);
    transition: transform .15s;
}
.internal-details[open] summary::before { transform: rotate(90deg); }
.internal-details > .form-grid { padding: 4px 16px 16px; }
fieldset.section { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 20px 0 0; min-width: 0; }
fieldset.section legend { font-weight: 700; padding: 0 6px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 10px; }
.check-group { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; background: var(--card); }
.check-group h4 { font-size: 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.check-group h4 i { color: var(--blue); }
.check { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); margin: 0; }
.form-card { padding: 24px; }
.form-narrow { max-width: 640px; }
.form-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.form-with-preview { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 28px; align-items: start; }

/* ---------- Website preview ---------- */
.preview { position: sticky; top: 90px; }
.preview-label { margin: 0 0 8px; font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.preview-card { border-radius: 14px; overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); background: var(--card); }
.preview-head { background: linear-gradient(135deg, var(--blue), #2c2f8f); color: #fff; padding: 18px 16px; }
.preview-head h3 { font-size: 18px; word-wrap: break-word; }
.preview-supplier { display: block; font-size: 12px; opacity: .85; margin-top: 4px; }
.preview-speed { display: inline-block; margin-top: 8px; background: rgba(255, 255, 255, .18); padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.preview-price { padding: 16px; font-size: 30px; font-weight: 800; color: var(--blue); }
.preview-price small { font-size: 14px; color: var(--ink-3); font-weight: 600; margin-left: 2px; }
.preview-features { list-style: none; margin: 0; padding: 0 16px 12px; color: var(--ink-2); font-size: 14px; }
.preview-features li::before { content: "\2713"; color: var(--green); font-weight: 700; margin-right: 8px; }
.preview-btn { display: block; margin: 0 16px 16px; padding: 10px; text-align: center; background: var(--orange); color: #fff; border-radius: var(--radius-sm); font-weight: 700; }
.preview .help { margin-top: 8px; }

/* ---------- Dialogs ---------- */
.dialog {
    border: 0;
    padding: 0;
    border-radius: 16px;
    width: min(640px, calc(100% - 32px));
    max-height: calc(100vh - 32px);
    box-shadow: var(--shadow-lg);
    background: var(--card);
    color: var(--ink);
}
.dialog-wide { width: min(980px, calc(100% - 32px)); }
.dialog::backdrop { background: rgba(17, 24, 39, .55); }
.dialog-form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); margin: 0; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 20px; }
.dialog-head h2 i { color: var(--blue); margin-right: 6px; }
.dialog-body { padding: 24px; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line); background: #fafbfc; }

/* ---------- Login / register ---------- */
body.auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 32px;
    text-align: center;
}
.auth-logo { height: 48px; margin-bottom: 16px; }
.auth-card h1 { font-size: 24px; }
.auth-card .lead { margin: 6px auto 20px; }
.auth-card .flash { text-align: left; }
.auth-form { text-align: left; display: flex; flex-direction: column; gap: 16px; }
.auth-link { margin: 16px 0 0; font-size: 14px; color: var(--ink-3); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .form-with-preview { grid-template-columns: 1fr; }
    .preview { position: static; }
}
@media (max-width: 720px) {
    .topbar-inner { gap: 8px; }
    .topnav { order: 3; width: 100%; margin-left: 0; }
    .topnav a { flex: 1; justify-content: center; }
    .topbar-right .btn span, .user-chip { display: none; }
    .page { padding: 16px 12px 80px; }
    .page-head h1 { font-size: 24px; }
    .form-grid { grid-template-columns: 1fr; }
    .dialog, .dialog-wide { width: 100%; max-height: 100vh; border-radius: 0; }
    .dialog-form { max-height: 100vh; }
    .result-count { margin-left: 0; width: 100%; }
    .auth-card { padding: 24px; }
}
