/* Admin panel styles — clean, modern, separate from the public Joomla theme. */

:root {
    --brand: #E76453;
    --brand-dark: #c54a3b;
    --ink: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --bg: #f5f6f8;
    --card: #fff;
    --ok: #16a34a;
    --warn: #d97706;
    --danger: #dc2626;
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow-x: hidden; }
body.admin-body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Open Sans', system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

.muted { color: var(--muted); }

/* ----- Top bar ----- */
.admin-topbar {
    display: flex;
    align-items: center;
    background: #1f2937;
    color: #fff;
    padding: 10px 20px;
    min-height: 60px;
    gap: 24px;
    flex-wrap: wrap;
}
.admin-brand {
    color: #fff !important;
    font-family: 'Oswald', sans-serif;
    font-size: 18px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
}
.admin-brand__tag {
    background: var(--brand);
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 2px;
    margin-left: 6px;
    text-transform: uppercase;
}
.admin-nav {
    display: flex;
    gap: 8px 6px;
    flex: 1;
    align-items: center;
    flex-wrap: wrap;
}
.admin-nav a {
    color: #d1d5db !important;
    padding: 5px 10px;
    border-radius: 4px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.05); /* Neat pill background */
    white-space: nowrap;
    display: inline-block;
    transition: all 0.2s ease;
    font-size: 13px;
}
.admin-nav a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff !important;
}
.admin-account {
    display: flex; align-items: center; gap: 12px;
    font-size: 13px;
}
.admin-account a { color: #d1d5db !important; }
.admin-account a:hover { color: #fff !important; }
.admin-account .muted { color: #9ca3af !important; }
.admin-logout { color: #fca5a5 !important; }

/* ----- Main content ----- */
.admin-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}
.admin-page-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 18px; flex-wrap: wrap; gap: 12px;
}
.admin-page-title {
    font-family: 'Oswald', sans-serif;
    font-size: 24px;
    margin: 0;
    color: var(--ink);
}

.admin-flash { margin-bottom: 16px; }
.alert {
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: 4px;
    margin-bottom: 8px;
}
.alert-success { background:#dcfce7; border-color:#86efac; color:#166534; }
.alert-error,
.alert-danger  { background:#fee2e2; border-color:#fca5a5; color:#991b1b; }
.alert-info    { background:#dbeafe; border-color:#93c5fd; color:#1e40af; }

/* ----- Stat grid (dashboard) ----- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px 18px;
}
.stat-card--alert { border-color: #fed7aa; background: #fff7ed; }
.stat-card__label {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--muted); margin-bottom: 4px;
}
.stat-card__value {
    font-family: 'Oswald', sans-serif;
    font-size: 28px; color: var(--ink); line-height: 1;
}
.stat-card__sub { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ----- Two col panels ----- */
.admin-two-col {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
}
@media (max-width: 900px) { .admin-two-col { grid-template-columns: 1fr; } }
.admin-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px 18px;
}
.admin-panel__header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px;
}
.admin-panel__header h2 { margin: 0; font-size: 16px; }
.admin-panel h2 { margin: 18px 0 8px; font-size: 16px; }

/* ----- Tables ----- */
.admin-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 16px;
}
.admin-table {
    width: 100%;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    border-collapse: collapse;
    overflow: hidden;
    margin-bottom: 16px;
}
.admin-table th, .admin-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    vertical-align: top;
}
.admin-table thead th {
    background: #f9fafb;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}
.admin-table tbody tr:hover { background: #fafafa; }
.admin-table tfoot td { background: #f9fafb; font-weight: 600; }
.totals-row td { background: #fffbeb; }
.admin-table .actions { white-space: nowrap; }
.admin-table .actions form, .admin-table .actions a { margin-right: 4px; }
.unread-row { background: #fffbeb !important; }
.low-stock { color: var(--danger); }

/* ----- Filter form ----- */
.admin-filter {
    display: flex; gap: 8px; margin-bottom: 16px;
}
.admin-filter .form-control { max-width: 320px; }

/* ----- Forms ----- */
.admin-form fieldset {
    background: var(--card);
    border: 1px solid var(--border) !important;
    border-radius: 6px !important;
    padding: 16px 18px !important;
    margin-bottom: 14px !important;
}
.admin-form legend {
    padding: 0 6px;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--brand);
    letter-spacing: 0.5px;
    font-weight: 600;
}
.form-row { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.form-row-inline { flex-direction: row; align-items: center; gap: 6px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .form-grid-2 { grid-template-columns: 1fr; } }
.form-control {
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font: inherit;
    width: 100%;
    background: #fff;
}
.form-control:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(231,100,83,.15);
}
.form-error { color: var(--danger); font-size: 12px; }
.form-actions { margin-top: 8px; display: flex; gap: 8px; }

label { font-weight: 600; font-size: 13px; }

/* ----- Buttons ----- */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 4px;
    border: 1px solid transparent;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    font-size: 13px;
    line-height: 1.4;
}
.btn-primary { background: var(--brand); color: #fff !important; }
.btn-primary:hover { background: var(--brand-dark); color: #fff !important; }
.btn-secondary { background: #fff; color: var(--ink) !important; border: 1px solid var(--border); }
.btn-secondary:hover { background: #f3f4f6; color: var(--ink) !important; }
.btn-danger { background: #fff; color: var(--danger) !important; border: 1px solid #fca5a5; }
.btn-danger:hover { background: var(--danger); color: #fff !important; }
.btn-tiny { padding: 4px 8px; font-size: 12px; }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-link { background: transparent; border: none; color: var(--danger); cursor: pointer; padding: 0; }

/* ----- Status pills ----- */
.status-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: #e5e7eb;
    color: #374151;
}
.status-pill--pending   { background:#fef3c7; color:#92400e; }
.status-pill--paid      { background:#dcfce7; color:#166534; }
.status-pill--shipped   { background:#dbeafe; color:#1e40af; }
.status-pill--delivered { background:#cffafe; color:#0e7490; }
.status-pill--cancelled { background:#fee2e2; color:#991b1b; }
.status-pill--featured  { background:#fef3c7; color:#92400e; }

/* ----- Pagination ----- */
.pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
    font-size: 13px;
}
.pagination a { color: var(--brand); }

/* ----- Login screen ----- */
.admin-login-wrap {
    min-height: calc(100vh - 80px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.admin-login-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 4px 20px rgba(0,0,0,.05);
}
.admin-login-card h1 {
    font-family: 'Oswald', sans-serif;
    margin: 0 0 4px;
    font-size: 22px;
}
.admin-login-card p.muted { margin: 0 0 18px; font-size: 13px; }
.login-back { margin-top: 14px; text-align: center; font-size: 12px; }
/* ---------- AI Scan ---------- */
.admin-nav__ai {
    background: linear-gradient(135deg, #f58220, #d36a0e) !important;
    color: #fff !important;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    white-space: nowrap;
}
.admin-nav__ai:hover { background: linear-gradient(135deg, #d36a0e, #b85a08); color: #fff !important; }

.ai-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}
.ai-card__head {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 16px; margin-bottom: 20px;
}
.ai-card h2 { margin: 0 0 4px; font-size: 18px; }
.ai-card p { margin: 0 0 16px; }

.ai-setup ol { margin: 8px 0 8px 20px; padding: 0; }
.ai-setup ol li { margin: 6px 0; }
.ai-setup code {
    background: rgba(0,0,0,.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

/* Drop zone / file input */
.ai-upload-form { display: flex; flex-direction: column; gap: 16px; }
.ai-dropzone {
    display: block;
    border: 2px dashed #cfd6df;
    border-radius: 12px;
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    background: #fafbfc;
}
.ai-dropzone:hover {
    border-color: #f58220;
    background: #fff7ee;
}
.ai-dropzone input[type="file"] { display: none; }
.ai-dropzone__inner { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ai-dropzone__icon { font-size: 48px; line-height: 1; }
.ai-dropzone__hint { font-size: 15px; color: var(--ink); }
.ai-dropzone__hint strong { color: #d36a0e; }

.ai-actions {
    display: flex; align-items: center; gap: 14px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.ai-submit-btn { font-size: 15px; padding: 12px 24px; }
.ai-model-tag {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 12px;
    background: rgba(0,0,0,.04);
    padding: 3px 8px;
    border-radius: 4px;
}

/* Review layout */
.ai-review-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
}
.ai-photo {
    position: sticky;
    top: 16px;
    align-self: start;
}
.ai-photo img {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
}
.ai-photo__cap { font-size: 12px; margin-top: 8px; text-align: center; }

.ai-table-wrap { overflow-x: auto; }
.ai-detections {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.ai-detections thead th {
    background: #f8fafc;
    text-align: left;
    padding: 10px 8px;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    color: var(--ink);
}
.ai-detections tbody td {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.ai-detections tbody tr:hover { background: #fafbfc; }
.ai-detections .col-check { width: 36px; text-align: center; }
.ai-detections .col-conf { width: 90px; text-align: center; }

.ai-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 7px 10px;
    font-size: 13px;
    background: #fff;
    color: var(--ink);
    font-family: inherit;
}
.ai-input:focus {
    outline: none;
    border-color: #f58220;
    box-shadow: 0 0 0 3px rgba(245,130,32,.12);
}
.ai-input--narrow { width: 90px; }
.ai-select { min-width: 160px; }
.ai-hint { font-size: 11px; margin-top: 4px; font-style: italic; }

.conf-pill {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: .3px;
}
.conf-pill--high { background: rgba(22,163,74,.12); color: #166534; }
.conf-pill--mid  { background: rgba(217,119,6,.12); color: #92400e; }
.conf-pill--low  { background: rgba(220,38,38,.12); color: #991b1b; }

@media (max-width: 900px) {
    .ai-review-layout { grid-template-columns: 1fr; }
    .ai-photo { position: static; }
    .ai-photo img { max-width: 320px; margin: 0 auto; display: block; }
}

/* ---------- AI quick-link card on dashboard ---------- */
.ai-quick-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: linear-gradient(135deg, #fff5e8 0%, #ffe9d3 100%);
    border: 1px solid #f8d5b0;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 24px;
    text-decoration: none;
    color: var(--ink);
    transition: transform .15s, box-shadow .15s;
}
.ai-quick-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(245,130,32,.15);
    color: var(--ink);
}
.ai-quick-card__icon { font-size: 36px; line-height: 1; }
.ai-quick-card__body { flex: 1; display: flex; flex-direction: column; }
.ai-quick-card__body strong { font-size: 16px; color: #d36a0e; }
.ai-quick-card__body span { font-size: 13px; color: var(--muted); }
.ai-quick-card__cta { color: #d36a0e; font-weight: 600; white-space: nowrap; }

/* ---------- AI Scan — browser detection canvas ---------- */
.ai-detect-status {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin: 12px 0;
    font-weight: 600;
}
.ai-detect-status--busy  { background: #fff7e6; color: #92400e; }
.ai-detect-status--ok    { background: #ecfdf5; color: #166534; }
.ai-detect-status--warn  { background: #fff7ed; color: #c2410c; }
.ai-detect-status--error { background: #fef2f2; color: #991b1b; }

.ai-detect-stage {
    margin: 12px 0;
    text-align: center;
    background: #fafbfc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
}
.ai-detect-stage canvas {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}
.ai-detect-summary { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.det-chip {
    background: #fff7ee;
    color: #d36a0e;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.det-chip small { color: var(--muted); margin-left: 4px; font-weight: 400; }

.ai-steps { margin: 8px 0 0 18px; padding: 0; }
.ai-steps li { margin: 8px 0; }

/* ---------- Result review rows ---------- */
.ai-source-photo {
    max-width: 280px;
    border-radius: 10px;
    border: 1px solid var(--border);
    display: block;
    margin: 0 auto 8px;
}
.ai-card--photo { text-align: center; padding: 16px; }

.det-row {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 14px;
    overflow: hidden;
    transition: border-color .2s;
}
.det-row.is-use  { border-color: #16a34a; }
.det-row.is-new  { border-color: #f58220; }
.det-row.is-skip { opacity: .55; }

.det-row__head {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 18px;
    background: #fafbfc;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.det-row__num {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: #f58220;
    color: #fff;
    font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 14px;
}
.det-row__title { flex: 1; font-size: 15px; }
.det-row__action { display: flex; gap: 6px; flex-wrap: wrap; }

.action-pill {
    display: inline-flex; align-items: center;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all .15s;
    color: var(--muted);
}
.action-pill input { display: none; }
.action-pill:hover { border-color: #cbd5e1; }
.action-pill--use:has(input:checked)  { background: #16a34a; color: #fff; border-color: #16a34a; }
.action-pill--new:has(input:checked)  { background: #f58220; color: #fff; border-color: #f58220; }
.action-pill--skip:has(input:checked) { background: #6b7280; color: #fff; border-color: #6b7280; }

.det-pane { padding: 16px 18px; }

/* Candidate cards */
.cand-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}
.cand-card {
    display: block;
    border: 2px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: all .15s;
    background: #fff;
}
.cand-card input { display: none; }
.cand-card:hover { border-color: #f58220; }
.cand-card.is-selected { border-color: #16a34a; box-shadow: 0 4px 14px rgba(22,163,74,.18); }
.cand-card__img {
    position: relative;
    aspect-ratio: 1 / 1;
    background: linear-gradient(135deg, #eaf6e2 0%, #f3faec 100%);
}
.cand-card__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cand-card__noimg {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    color: #b6c7b8;
    font-size: 36px;
}
.cand-card__score {
    position: absolute; top: 6px; right: 6px;
    background: rgba(0,0,0,.6); color: #fff;
    padding: 2px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 700;
}
.cand-card__body { padding: 8px 10px 10px; }
.cand-card__name { font-weight: 600; font-size: 13px; line-height: 1.3; color: var(--ink); }
.cand-card__meta { font-size: 11px; color: var(--muted); margin: 2px 0; }
.cand-card__price { font-weight: 700; color: #d36a0e; font-size: 13px; }
.cand-card__hint {
    display: inline-block;
    font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
    background: #fff7ee; color: #d36a0e;
    padding: 2px 6px; border-radius: 4px; margin-top: 4px;
}

.det-row__add-stock { margin-top: 12px; font-size: 13px; }
.det-row__add-stock input { margin: 0 6px; }

/* "Create new" form grid */
.new-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.new-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.new-grid .ai-input { width: 100%; }

/* Sticky apply bar */
.ai-actions--sticky {
    position: sticky; bottom: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 14px 18px;
    margin: 18px -18px -18px;
    z-index: 10;
    box-shadow: 0 -4px 12px rgba(0,0,0,.04);
}

.btn--pulse { animation: btnPulse 1.4s ease-in-out 2; }
@keyframes btnPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.04); }
}

@media (max-width: 720px) {
    .det-row__head { padding: 12px; }
    .det-row__action { width: 100%; justify-content: stretch; }
    .action-pill { flex: 1; justify-content: center; padding: 8px 6px; font-size: 12px; }
    .cand-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
    .admin-topbar {
        height: auto;
        flex-direction: column;
        align-items: stretch;
        padding: 14px 16px;
        gap: 12px;
    }
    .admin-nav {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
        gap: 6px;
    }
    .admin-nav a {
        padding: 6px 10px;
        font-size: 13px;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 4px;
        display: inline-block;
    }
    .admin-nav a.admin-nav__ai {
        background: linear-gradient(135deg, #f58220, #d36a0e) !important;
        color: #fff !important;
        font-weight: 600;
    }
    .admin-nav a.admin-nav__ai:hover {
        background: linear-gradient(135deg, #d36a0e, #b85a08) !important;
    }
    .admin-account {
        width: 100%;
        flex-wrap: wrap;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding-top: 12px;
        gap: 12px;
        justify-content: flex-start;
    }
}
