/* Woo Auditor — single stylesheet, hand-written, no build step */

:root {
    --bg:       #f5f5f5;
    --surface:  #ffffff;
    --border:   #e0e0e0;
    --text:     #1a1a1a;
    --muted:    #6b7280;
    --primary:  #2563eb;
    --primary-h:#1d4ed8;
    --danger:   #dc2626;
    --warn:     #d97706;
    --success:  #16a34a;
    --red-bg:   #fef2f2;
    --amber-bg: #fffbeb;
    --green-bg: #f0fdf4;
    --nav-bg:   #1e293b;
    --nav-text: #e2e8f0;
}

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

body {
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 0.9rem;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ── Nav ───────────────────────────────────────────────────── */

nav {
    background: var(--nav-bg);
    color: var(--nav-text);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: 48px;
    position: sticky;
    top: 0;
    z-index: 100;
}
nav .brand { font-weight: 700; font-size: 1rem; color: #fff; margin-right: auto; }
nav a { color: var(--nav-text); text-decoration: none; font-size: 0.85rem; }
nav a:hover { color: #fff; }
nav form { display: inline; }
nav button.logout {
    background: none; border: 1px solid rgba(255,255,255,.3); color: var(--nav-text);
    padding: .25rem .75rem; border-radius: 4px; cursor: pointer; font-size: .85rem;
}
nav button.logout:hover { background: rgba(255,255,255,.1); }
nav a.active { color: #fff; font-weight: 600; }

/* ── Store banner + switcher ────────────────────────────────── */

.store-banner {
    position: sticky;
    top: 48px;
    z-index: 99;
    padding: .2rem 1.5rem;
    font-size: .72rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.store-switcher { display: flex; align-items: center; }
.store-switcher select {
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.25);
    color: var(--nav-text);
    border-radius: 4px;
    padding: .2rem .5rem;
    font-size: .8rem;
    cursor: pointer;
}
.store-switcher select:focus { outline: none; }
.store-switcher select option { background: var(--nav-bg); color: var(--nav-text); }

/* ── Layout ─────────────────────────────────────────────────── */

main { width: 90%; margin: 1.5rem auto; padding: 0; }

h1 { font-size: 1.3rem; margin-bottom: 1rem; }
h2 { font-size: 1.1rem; margin-bottom: .75rem; }

/* ── Cards ──────────────────────────────────────────────────── */

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}
.card .label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.card .value { font-size: 1.5rem; font-weight: 700; margin-top: .25rem; }
.card .sub   { font-size: .75rem; color: var(--muted); }

/* ── Toolbar ────────────────────────────────────────────────── */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .75rem 1rem;
}
.toolbar input[type=text], .toolbar select {
    padding: .35rem .6rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: .85rem;
    background: var(--bg);
}
.toolbar label { font-size: .8rem; color: var(--muted); }

/* ── Tables ─────────────────────────────────────────────────── */

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left; padding: .6rem .75rem;
    font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--primary); }
th.sort-asc::after  { content: ' ↑'; }
th.sort-desc::after { content: ' ↓'; }
td { padding: .55rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

td.thumbnail img { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; }
td.thumbnail .no-img {
    width: 48px; height: 48px; background: var(--border);
    border-radius: 4px; display: flex; align-items: center;
    justify-content: center; color: var(--muted); font-size: .7rem;
}

/* ── RAG scores ─────────────────────────────────────────────── */

.score {
    display: inline-block;
    padding: .2rem .5rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: .85rem;
    min-width: 36px;
    text-align: center;
}
.rag-red   .score, .score.rag-red   { background: var(--red-bg);   color: var(--danger); }
.rag-amber .score, .score.rag-amber { background: var(--amber-bg); color: var(--warn);   }
.rag-green .score, .score.rag-green { background: var(--green-bg); color: var(--success);}
.score.rag-none { background: var(--border); color: var(--muted); }

/* ── Badges ─────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: .15rem .45rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
}
.badge-red    { background: var(--red-bg);   color: var(--danger); }
.badge-amber  { background: var(--amber-bg); color: var(--warn);   }
.badge-green  { background: var(--green-bg); color: var(--success);}
.badge-grey   { background: var(--border);   color: var(--muted);  }
.badge-blue   { background: #eff6ff;         color: var(--primary);}

/* ── Buttons ────────────────────────────────────────────────── */

.btn {
    display: inline-block; padding: .35rem .8rem; border-radius: 4px;
    font-size: .85rem; font-weight: 500; cursor: pointer;
    border: 1px solid transparent; text-decoration: none; line-height: 1.4;
}
.btn-primary  { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-h); border-color: var(--primary-h); }
.btn-danger   { background: var(--danger);  color: #fff; border-color: var(--danger);  }
.btn-outline  { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: .2rem .55rem; font-size: .8rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Alerts ─────────────────────────────────────────────────── */

.alert { padding: .75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.alert-error { background: var(--red-bg);   color: var(--danger);  border: 1px solid #fca5a5; }
.alert-info  { background: #eff6ff;         color: var(--primary); border: 1px solid #bfdbfe; }
.alert-success { background: var(--green-bg); color: var(--success); border: 1px solid #86efac; }

/* ── Forms ──────────────────────────────────────────────────── */

label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .35rem; }
input[type=email], input[type=text], select, textarea {
    width: 100%; padding: .5rem .75rem;
    border: 1px solid var(--border); border-radius: 6px;
    font-size: .9rem; background: var(--surface);
    transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
button[type=submit], button[type=button] {
    padding: .5rem 1.25rem; border-radius: 6px; font-size: .9rem;
    font-weight: 600; cursor: pointer; border: none; transition: background .15s;
}

/* ── Login page ─────────────────────────────────────────────── */

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 2rem; width: 100%; max-width: 380px;
}
.login-box h1 { font-size: 1.3rem; margin-bottom: .25rem; }
.login-box h2 { font-size: 1rem; color: var(--muted); margin-bottom: 1.25rem; font-weight: 400; }
.login-box label { margin-top: 1rem; }
.login-box input { margin-bottom: .75rem; }
.login-box button[type=submit] {
    width: 100%; background: var(--primary); color: #fff; margin-top: .5rem;
}
.login-box button[type=submit]:hover { background: var(--primary-h); }
.login-box a { color: var(--primary); font-size: .85rem; }

/* ── Toggle switch ──────────────────────────────────────────── */

.toggle {
    position: relative; display: inline-block; width: 38px; height: 22px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
    position: absolute; inset: 0; background: var(--border);
    border-radius: 999px; cursor: pointer; transition: background .2s;
}
.toggle input:checked + .slider { background: var(--success); }
.toggle .slider::before {
    content: ''; position: absolute;
    width: 16px; height: 16px; border-radius: 50%;
    left: 3px; bottom: 3px; background: #fff;
    transition: transform .2s;
}
.toggle input:checked + .slider::before { transform: translateX(16px); }
.toggle input:disabled + .slider { opacity: .5; cursor: not-allowed; }

/* ── Modal ──────────────────────────────────────────────────── */

.modal-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 100;
    align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: var(--surface); border-radius: 10px;
    padding: 1.5rem; max-width: 440px; width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal h2 { margin-bottom: 1rem; }
.modal table td { border: none; padding: .25rem 0; }
.modal table td:first-child { color: var(--muted); font-size: .85rem; min-width: 160px; }
.modal .modal-actions { margin-top: 1.25rem; display: flex; gap: .5rem; justify-content: flex-end; }

/* ── Product detail ─────────────────────────────────────────── */

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-section {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; padding: 1.25rem;
}
.detail-section h3 {
    font-size: .8rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); margin-bottom: .75rem;
}
.detail-section .field { margin-bottom: .85rem; }
.detail-section .field-label { font-size: .75rem; color: var(--muted); margin-bottom: .2rem; }
.detail-section .field-value { font-size: .9rem; white-space: pre-wrap;align-content: flex-start; }

.score-row { display: flex; align-items: center; gap .75rem; margin-bottom: .5rem; }
.score-row .score-label { flex: 1; font-weight: 500; }
.score-row .score-rationale { font-size: .8rem; color: var(--muted); margin-top: .2rem; }

.key-issues { list-style: disc; padding-left: 1.25rem; }
.key-issues li { margin-bottom: .25rem; font-size: .9rem; }

.audit-meta {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; padding: 1rem 1.25rem; margin-top: 1rem;
    display: flex; flex-wrap: wrap; gap: 1.5rem; font-size: .8rem; color: var(--muted);
}
.audit-meta span { display: flex; flex-direction: column; }
.audit-meta strong { color: var(--text); font-size: .85rem; }

.product-sticky-header {
    position: sticky;
    top: 48px;
    z-index: 90;
    background: var(--bg);
    padding: 1rem 0 .75rem;
    margin-bottom: .75rem;
    border-bottom: 1px solid var(--border);
}

/* Collapsible sections */
details.detail-section > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    user-select: none;
    margin-bottom: 0;
    background: #eef2f7;
    padding: .85rem 1.25rem;
    border-radius: 6px 6px 0 0;
    border-bottom: 1px solid var(--border);
}
details.detail-section > summary::-webkit-details-marker { display: none; }
details.detail-section > summary::after { content: none; }
details[open].detail-section > summary {
    padding-bottom: .85rem;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 6px 6px 0 0;
}
details.detail-section:not([open]) > summary {
    border-radius: 6px;
    border-bottom: none;
}
.summary-toggle-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: .75rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
    text-transform: none;
    letter-spacing: 0;
    flex-shrink: 0;
    text-decoration: underline dotted;
}

/* ── Pagination ─────────────────────────────────────────────── */

.pagination {
    display: flex; align-items: center; gap: .35rem;
    margin-top: 1rem; justify-content: flex-end;
}
.pagination a, .pagination span {
    display: inline-block; padding: .3rem .65rem;
    border: 1px solid var(--border); border-radius: 4px;
    font-size: .82rem; color: var(--text); text-decoration: none;
}
.pagination a:hover { background: var(--bg); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Misc ───────────────────────────────────────────────────── */

.muted { color: var(--muted); }
.text-sm { font-size: .8rem; }
.mt-1 { margin-top: .5rem; }
.mb-1 { margin-bottom: .5rem; }
.flex { display: flex; gap: .5rem; align-items: center; }
.failed-detail { font-size: .75rem; color: var(--danger); max-width: 240px;
                 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[title] { cursor: help; }

/* Push to WooCommerce — Phase 3.5 */

.push-btn-wrap { margin-top: .4rem; }
.word-count { font-size: .72rem; color: #999; margin-top: .3rem; }
.btn-push {
    font-size: .75rem;
    padding: .2rem .55rem;
    border: 1px solid var(--primary);
    border-radius: 4px;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    line-height: 1.4;
    transition: background .12s, color .12s;
}
.btn-push:hover:not(:disabled) { background: var(--primary); color: #fff; }
.btn-push:disabled { opacity: .45; cursor: not-allowed; border-color: var(--border); color: var(--muted); }

.revert-wrap { margin-top: .3rem; }
.revert-link { font-size: .72rem; color: var(--warn); text-decoration: underline dotted; cursor: pointer; }
.revert-link:hover { color: var(--danger); }

/* Modals */
.push-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}
.push-modal-overlay[hidden] { display: none; }
.push-modal-box {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,.22);
    width: 100%; max-width: 820px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
}
.push-modal-heading {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
}
.push-modal-preview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}
.push-preview-label {
    font-size: .75rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: .35rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.push-preview-label-sub { font-weight: 400; text-transform: none; letter-spacing: 0; }
.push-preview-current {
    font-size: .82rem;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: .5rem .65rem;
    min-height: 80px;
    background: var(--bg);
    white-space: pre-wrap;
    word-break: break-word;
}
.push-textarea {
    width: 100%;
    font-size: .82rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: .5rem .65rem;
    font-family: inherit;
    resize: none;
    min-height: 400px;
    max-height: 800px;
    overflow-y: auto;
    line-height: 1.5;
}
.push-textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.push-char-count {
    font-size: .72rem;
    margin-top: .25rem;
    color: var(--muted);
}
.push-char-count.char-amber { color: var(--warn); }
.push-char-count.char-red   { color: var(--danger); font-weight: 600; }
.push-html-hint {
    font-size: .72rem;
    color: var(--muted);
    margin-top: .25rem;
}
.push-modal-error {
    font-size: .82rem;
    color: var(--danger);
    background: var(--red-bg);
    border: 1px solid #fca5a5;
    border-radius: 4px;
    padding: .5rem .75rem;
    margin-bottom: .75rem;
}
.push-modal-actions {
    display: flex;
    gap: .5rem;
    justify-content: flex-end;
    padding-top: .75rem;
    border-top: 1px solid var(--border);
}
.btn-danger {
    background: var(--danger); color: #fff; border-color: var(--danger);
}
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

/* Push success banner (appears in a tr below the field row) */
.push-banner {
    padding: .4rem .75rem;
    border-radius: 4px;
    font-size: .8rem;
    margin: .25rem 0;
}
.push-banner-success {
    background: var(--green-bg);
    color: var(--success);
    border: 1px solid #bbf7d0;
}
