/* ═══════════════════════════════════════════════════════════
   Scan2Return — Warm Editorial Design System
   Amir-approved palette: cream paper, ink text, terracotta accent
   No dark purple. No glassmorphism. No AI-generic.
   ═══════════════════════════════════════════════════════════ */

/* ── Design Tokens ── */
:root {
    --paper:       #f6f1e7;
    --paper-deep:  #efe7d7;
    --card:        #fffdf8;
    --ink:         #232019;
    --ink-soft:    #6d6454;
    --ink-faint:   #9b9080;
    --line:        #e0d5c1;
    --line-strong: #c8b99d;
    --terra:       #b8501e;
    --terra-deep:  #93390f;
    --success:     #2d6a4f;
    --success-bg:  #e8f5e9;
    --error:       #c0392b;
    --error-bg:    #fdecea;
    --radius:      3px;
    --max-width:   720px;
}

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

/* ── Base ── */
html { font-size: 17px; }
body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    color: var(--ink);
    background: var(--paper);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--terra); text-decoration: none; }
a:hover { color: var(--terra-deep); text-decoration: underline; }

img { max-width: 100%; height: auto; }

/* ── Masthead ── */
.masthead {
    background: var(--paper);
    border-bottom: 3px double var(--line-strong);
    padding: 0 1rem;
}
.masthead-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
    color: var(--ink);
}
.brand:hover { text-decoration: none; }
.brand-icon { color: var(--terra); flex-shrink: 0; }
.brand-name {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.brand-chip {
    font-family: ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: var(--terra);
    color: #fff;
    padding: 1px 6px;
    border-radius: 2px;
    font-weight: 600;
}
.main-nav {
    display: flex;
    gap: 1.25rem;
}
.main-nav a {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
    text-decoration: none;
    font-weight: 500;
    padding: 4px 0;
}
.main-nav a:hover {
    color: var(--terra);
    text-decoration: none;
}

/* ── Main Content ── */
main {
    flex: 1;
    max-width: var(--max-width);
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1rem 3rem;
}

/* ── Hero ── */
.hero {
    text-align: center;
    padding: 2rem 0 1.5rem;
}
.hero h1 {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 2rem;
    line-height: 1.25;
    margin-bottom: 0.75rem;
    letter-spacing: -0.01em;
}
.lede {
    color: var(--ink-soft);
    font-size: 1.05rem;
    max-width: 560px;
    margin: 0 auto 1.5rem;
    line-height: 1.65;
}

/* ── Stats ── */
.stats-row {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}
.stat {
    text-align: center;
}
.stat-num {
    display: block;
    font-family: ui-monospace, 'SF Mono', monospace;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--terra);
    line-height: 1.2;
}
.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-faint);
}

/* ── Cards ── */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 1.5rem;
}
.card h2 {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

/* ── Found Card (find.php) ── */
.found-card {
    text-align: center;
    max-width: 440px;
    margin: 1rem auto 1.5rem;
}
.found-header { margin-bottom: 1.5rem; }
.found-icon { font-size: 3rem; display: block; margin-bottom: 0.5rem; }
.found-header h1 {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}
.found-subtitle {
    color: var(--ink-soft);
    font-size: 0.9rem;
}
.owner-info {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #faf7f0;
    border-radius: var(--radius);
}
.owner-name {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.3rem;
    margin-bottom: 0.25rem;
}
.key-desc {
    font-size: 0.95rem;
    color: var(--ink-soft);
    margin-bottom: 0.5rem;
}
.reward-badge {
    display: inline-block;
    background: var(--terra);
    color: #fff;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Contact action buttons */
.contact-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: background 0.15s, transform 0.1s;
    line-height: 1.3;
}
.btn:active { transform: translateY(1px); }
.btn-call {
    background: var(--ink);
    color: #fff;
}
.btn-call:hover {
    background: var(--terra);
    color: #fff;
    text-decoration: none;
}
.btn-email {
    background: var(--terra);
    color: #fff;
}
.btn-email:hover {
    background: var(--terra-deep);
    color: #fff;
    text-decoration: none;
}
.btn-sm {
    font-size: 0.8rem;
    padding: 0.45rem 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.btn-ghost {
    background: transparent;
    color: var(--ink-soft);
    border: 1px solid var(--line);
}
.btn-ghost:hover {
    background: var(--paper-deep);
    color: var(--ink);
    text-decoration: none;
}
.btn-disabled {
    opacity: 0.4;
    pointer-events: none;
    background: var(--paper-deep);
    color: var(--ink-faint);
    border: 1px solid var(--line);
}
.alt-phone {
    font-size: 0.9rem;
    color: var(--ink-soft);
    margin-bottom: 1rem;
}
.found-note {
    font-size: 0.8rem;
    color: var(--ink-faint);
    font-family: ui-monospace, monospace;
}

/* ── Message Cards (error/info) ── */
.message-card {
    max-width: 440px;
    margin: 2rem auto;
    text-align: center;
}
.message-card h2 {
    font-family: Georgia, serif;
    margin-bottom: 0.75rem;
}
.message-card p { color: var(--ink-soft); margin-bottom: 0.5rem; }

/* ── How It Works ── */
.how-list {
    list-style: none;
    counter-reset: how;
}
.how-list li {
    counter-increment: how;
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--line);
}
.how-list li:last-child { border-bottom: none; }
.how-list li::before {
    content: counter(how);
    font-family: Georgia, serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--terra);
    flex-shrink: 0;
    width: 2rem;
    text-align: center;
    line-height: 1.3;
}
.how-list li strong {
    display: block;
    font-size: 0.95rem;
    margin-bottom: 0.15rem;
}
.how-list li span {
    color: var(--ink-soft);
    font-size: 0.85rem;
}

/* ── FAQ ── */
.faq-card dl { margin: 0; }
.faq-card dt {
    font-weight: 600;
    font-size: 0.95rem;
    margin-top: 1rem;
    color: var(--ink);
}
.faq-card dd {
    color: var(--ink-soft);
    font-size: 0.85rem;
    margin-left: 0;
    margin-top: 0.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--line);
}
.faq-card dd:last-child { border-bottom: none; padding-bottom: 0; }

/* ── Quick Actions ── */
.action-grid {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.admin-quick {
    text-align: center;
}

/* ── Admin Header ── */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.admin-header h1 {
    font-family: Georgia, serif;
    font-size: 1.5rem;
}
.admin-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}
.stat-card .stat-num {
    font-size: 2rem;
    display: block;
}
.stat-card .stat-label {
    display: block;
    margin-top: 0.25rem;
}
.stat-detail {
    display: block;
    font-size: 0.75rem;
    color: var(--ink-faint);
    margin-top: 0.25rem;
}

/* ── Tables ── */
.table-wrap {
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: var(--card);
}
.data-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-faint);
    background: var(--paper-deep);
    border-bottom: 2px solid var(--line-strong);
    white-space: nowrap;
}
.data-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fefcf7; }
.mono {
    font-family: ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
    font-size: 0.8rem;
}

/* ── Badges ── */
.badge {
    display: inline-block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 2px;
    font-weight: 600;
}
.badge-active {
    background: #e8f5e9;
    color: #2d6a4f;
}
.badge-inactive {
    background: #fdecea;
    color: #c0392b;
}

/* ── Flash Messages ── */
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border-left: 4px solid;
}
.flash-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: var(--success);
}
.flash-error {
    background: var(--error-bg);
    color: var(--error);
    border-color: var(--error);
}

/* ── Forms ── */
.admin-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.form-row {
    display: flex;
    gap: 1rem;
}
.form-row .form-field { flex: 1; }
.form-field {
    display: flex;
    flex-direction: column;
}
.field-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-soft);
    margin-bottom: 0.3rem;
}
.field-input {
    font-family: inherit;
    font-size: 1rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    transition: border-color 0.15s;
}
.field-input:focus {
    outline: none;
    border-color: var(--terra);
    box-shadow: 0 0 0 2px rgba(184, 80, 30, 0.15);
}
select.field-input { cursor: pointer; }
.field-help {
    font-size: 0.75rem;
    color: var(--ink-faint);
    margin-top: 0.25rem;
}
.form-help {
    font-size: 0.85rem;
    color: var(--ink-soft);
    margin-bottom: 0.25rem;
}
.form-field-checkbox {
    flex-direction: row;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0;
}
.form-field-checkbox input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    margin-top: 0.15rem;
    accent-color: var(--terra);
    flex-shrink: 0;
}
.form-field-checkbox .field-help {
    display: block;
    margin-top: 0.15rem;
}

/* ── Auth Card ── */
.auth-card {
    max-width: 380px;
    margin: 3rem auto;
    text-align: center;
}
.auth-card h1 {
    font-family: Georgia, serif;
    margin-bottom: 1.5rem;
}
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.auth-form .btn { width: 100%; }

/* ── QR Generated Display ── */
.qr-generated h2 {
    font-family: Georgia, serif;
    margin-bottom: 1rem;
}
.qr-display {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    flex-wrap: wrap;
}
.qr-display img {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    flex-shrink: 0;
}
.qr-details {
    flex: 1;
    min-width: 200px;
    font-size: 0.9rem;
    line-height: 1.8;
}
.qr-code-str {
    font-size: 0.7rem !important;
    word-break: break-all;
    color: var(--ink-faint);
    background: #faf7f0;
    padding: 4px 8px;
    border-radius: 2px;
    margin-top: 0.5rem;
}
.qr-url {
    font-size: 0.75rem;
    word-break: break-all;
    margin-top: 0.25rem;
}
.qr-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* ── Pagination ── */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.pg-note {
    font-family: ui-monospace, monospace;
    font-size: 0.8rem;
    color: var(--ink-faint);
}
.scan-count {
    font-size: 0.8rem;
    color: var(--ink-faint);
    margin-bottom: 0.75rem;
}

/* ── Empty State ── */
.empty-card {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--ink-faint);
}
.empty-card p {
    font-size: 0.95rem;
}

/* ── Back Link ── */
.back-link {
    margin-top: 1rem;
    font-size: 0.85rem;
}

/* ── Footer ── */
.site-footer {
    text-align: center;
    padding: 2rem 1rem;
    border-top: 3px double var(--line-strong);
    background: var(--paper-deep);
}
.site-footer p {
    color: var(--ink-soft);
    font-size: 0.85rem;
    line-height: 1.6;
}
.footer-meta {
    font-family: ui-monospace, monospace;
    font-size: 0.7rem !important;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-faint) !important;
    margin-top: 0.25rem;
}

/* ── Focus ── */
:focus-visible {
    outline: 2px solid var(--terra);
    outline-offset: 2px;
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ── Mobile ── */
@media (max-width: 768px) {
    html { font-size: 16px; }
    .masthead-inner { flex-direction: column; gap: 0.5rem; }
    .main-nav { gap: 1rem; }
    .hero h1 { font-size: 1.5rem; }
    .card { padding: 1.25rem; }
    .form-row { flex-direction: column; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .admin-header { flex-direction: column; }
    .qr-display { flex-direction: column; align-items: center; }
    .contact-actions .btn { font-size: 1rem; padding: 0.85rem 1rem; }
    .data-table { font-size: 0.75rem; }
    .data-table th, .data-table td { padding: 0.4rem 0.5rem; }
}
