/* =======================================================================
   ZOL — Admin: customer management + scanner
   ======================================================================= */

/* Generic admin page layout (reusable) -------------------------------- */
.admin-page {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--paper);
    color: var(--ink);
}
.admin-page .shop-header {
    background: var(--shop-primary);
    color: var(--shop-on-primary);
    padding: 16px 24px;
}
.admin-page .shop-header .btn-ghost {
    background: rgba(255, 255, 255, 0.08);
    color: var(--shop-on-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

.admin-container {
    max-width: 980px;
    margin: 0 auto;
    padding: 24px 20px 64px;
}

.admin-title {
    font-family: var(--font-display);
    font-size: 30px;
    color: var(--forest);
    margin: 0 0 4px;
}
.admin-subtitle {
    color: rgba(14, 31, 20, 0.6);
    font-size: 15px;
    margin-bottom: 24px;
}

/* Home dashboard tiles ------------------------------------------------ */
.home-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 24px;
}
.home-tile {
    background: #ffffff;
    border: 1px solid var(--paper-3);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    text-align: left;
    cursor: pointer;
    transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.home-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
    border-color: var(--shop-primary);
}
.home-tile-icon {
    width: 32px;
    height: 32px;
    color: var(--shop-primary);
    margin-bottom: 8px;
}
.home-tile-label {
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--forest);
    font-weight: 500;
}
.home-tile-desc {
    font-size: 13px;
    color: rgba(14, 31, 20, 0.6);
    line-height: 1.4;
}

/* Search + filter bar ------------------------------------------------- */
.list-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
}
.list-search {
    flex: 1;
    min-width: 200px;
    position: relative;
}
.list-search input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    border: 1px solid var(--paper-3);
    border-radius: var(--radius-sm);
    background: #ffffff;
}
.list-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(14, 31, 20, 0.4);
}
.filter-pills {
    display: flex;
    gap: 6px;
    background: var(--paper-2);
    padding: 4px;
    border-radius: var(--radius-sm);
}
.filter-pill {
    padding: 6px 14px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: rgba(14, 31, 20, 0.7);
    cursor: pointer;
    font-weight: 500;
}
.filter-pill.is-active {
    background: #ffffff;
    color: var(--forest);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Customer list ------------------------------------------------------- */
.customer-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.customer-row {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid var(--paper-3);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color 120ms ease;
}
.customer-row:hover {
    border-color: var(--shop-primary);
}
.customer-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--paper-2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.customer-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.customer-avatar .placeholder {
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--forest);
    font-weight: 600;
}
.customer-info {
    min-width: 0; /* allow truncation */
}
.customer-name {
    font-weight: 500;
    color: var(--ink);
    margin: 0 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.customer-meta {
    font-size: 13px;
    color: rgba(14, 31, 20, 0.55);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.customer-meta .mono {
    font-family: 'Menlo', 'Monaco', monospace;
}
.customer-status-pill {
    flex-shrink: 0;
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 999px;
    font-weight: 500;
}
.customer-status-pill.active {
    background: rgba(47, 107, 72, 0.12);
    color: var(--success);
}
.customer-status-pill.flagged {
    background: rgba(181, 74, 61, 0.12);
    color: var(--error);
}

.list-empty {
    text-align: center;
    padding: 48px 20px;
    color: rgba(14, 31, 20, 0.55);
}
.list-empty-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    color: rgba(14, 31, 20, 0.25);
}

/* Pagination ---------------------------------------------------------- */
.list-pager {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    font-size: 14px;
    color: rgba(14, 31, 20, 0.65);
}

/* Customer detail view ------------------------------------------------ */
.detail-card {
    background: #ffffff;
    border: 1px solid var(--paper-3);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}
.detail-header {
    background: var(--paper-2);
    padding: 24px;
    display: flex;
    gap: 18px;
    align-items: center;
    border-bottom: 1px solid var(--paper-3);
}
.detail-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.detail-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.detail-avatar .placeholder {
    font-family: var(--font-display);
    font-size: 32px;
    color: var(--forest);
    font-weight: 600;
}
.detail-name {
    font-family: var(--font-display);
    font-size: 26px;
    color: var(--forest);
    margin: 0 0 4px;
    line-height: 1.1;
}
.detail-meta {
    font-size: 14px;
    color: rgba(14, 31, 20, 0.6);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.detail-meta .mono { font-family: 'Menlo', 'Monaco', monospace; }

.detail-body {
    padding: 24px;
}
.detail-section {
    margin-bottom: 28px;
}
.detail-section:last-child { margin-bottom: 0; }
.detail-section h4 {
    font-family: var(--font-display);
    font-size: 16px;
    color: var(--forest);
    margin: 0 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.detail-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px 16px;
    font-size: 14px;
}
.detail-grid dt {
    color: rgba(14, 31, 20, 0.55);
}
.detail-grid dd {
    margin: 0;
    color: var(--ink);
}

.detail-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0 24px 24px;
}
.detail-actions .btn { flex: 1; min-width: 120px; }
.detail-actions .btn-danger {
    background: var(--error);
    color: #ffffff;
    border-color: var(--error);
}
.detail-actions .btn-danger:hover {
    background: #9c3f33;
}

/* Status banner on detail */
.status-banner {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
}
.status-banner.flagged {
    background: rgba(181, 74, 61, 0.1);
    color: var(--error);
    border: 1px solid rgba(181, 74, 61, 0.25);
}
.status-banner strong { display: block; margin-bottom: 2px; }

/* Access log table */
.access-log {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}
.access-log-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding: 6px 10px;
    background: var(--paper);
    border-radius: var(--radius-sm);
}
.access-log-row .who { color: var(--ink); }
.access-log-row .when { color: rgba(14, 31, 20, 0.55); white-space: nowrap; }

/* Photo viewer modal -------------------------------------------------- */
.photo-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(14, 31, 20, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.photo-modal[hidden] { display: none !important; }
.photo-modal-inner {
    max-width: 800px;
    width: 100%;
    background: #ffffff;
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.photo-modal-head {
    padding: 14px 20px;
    background: var(--paper-2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--paper-3);
}
.photo-modal-head h3 {
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--forest);
    margin: 0;
}
.photo-modal-body {
    background: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    max-height: 70vh;
}
.photo-modal-body img {
    max-width: 100%;
    max-height: 70vh;
    display: block;
}
.photo-modal-foot {
    padding: 12px 20px;
    font-size: 12px;
    color: rgba(14, 31, 20, 0.6);
    background: var(--paper-2);
    border-top: 1px solid var(--paper-3);
}

/* Scanner ------------------------------------------------------------- */
.scanner-page {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--ink);
    color: var(--paper);
    display: flex;
    flex-direction: column;
}
.scanner-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(0,0,0,0.4);
}
.scanner-header h2 {
    font-family: var(--font-display);
    font-size: 18px;
    color: currentColor;
    margin: 0;
    font-weight: 500;
}
.scanner-header .btn-back {
    color: var(--paper);
    background: rgba(255,255,255,0.1);
    position: relative;
    top: auto;
    left: auto;
    flex-shrink: 0;
}

#scanner-reader {
    flex: 1;
    background: #000;
    overflow: hidden;
    position: relative;
}
#scanner-reader video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

.scanner-instructions {
    padding: 16px 20px 24px;
    text-align: center;
    background: rgba(0,0,0,0.3);
    font-size: 14px;
    color: rgba(255,255,255,0.85);
}

/* Scanner result modal */
.scan-result {
    position: fixed;
    inset: 0;
    z-index: 250;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(14, 31, 20, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.scan-result[hidden] { display: none !important; }
.scan-result-card {
    width: 100%;
    max-width: 420px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    background: #ffffff;
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    border: 4px solid var(--success);
}
.scan-result-card.is-flagged {
    border-color: var(--error);
}
.scan-result-card.is-error {
    border-color: var(--accent);
}
.scan-banner {
    background: var(--success);
    color: #ffffff;
    padding: 16px 20px;
    text-align: center;
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 500;
}
.scan-result-card.is-flagged .scan-banner {
    background: var(--error);
}
.scan-result-card.is-error .scan-banner {
    background: var(--accent);
}
.scan-result-photo {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 20px auto 16px;
    background: var(--paper-2);
    border: 4px solid #ffffff;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.scan-result-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.scan-result-photo .placeholder {
    font-family: var(--font-display);
    font-size: 48px;
    color: var(--forest);
    font-weight: 600;
}
.scan-result-body {
    padding: 0 24px 16px;
    text-align: center;
}
.scan-result-name {
    font-family: var(--font-display);
    font-size: 28px;
    color: var(--forest);
    margin: 0 0 4px;
    line-height: 1.1;
}
.scan-result-number {
    font-family: 'Menlo', 'Monaco', monospace;
    font-size: 14px;
    color: rgba(14, 31, 20, 0.55);
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}
.scan-result-flag-reason {
    background: rgba(181, 74, 61, 0.1);
    color: var(--error);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    text-align: left;
}
.scan-result-activity {
    margin-top: 16px;
    padding: 12px 14px;
    background: var(--paper, #f7f5ee);
    border-radius: var(--radius-sm);
    text-align: left;
}
.scan-result-activity-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(14, 31, 20, 0.55);
    margin: 0 0 8px 0;
}
.scan-result-activity-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 4px 0;
    font-size: 13px;
    border-bottom: 1px solid rgba(14, 31, 20, 0.06);
}
.scan-result-activity-row:last-child {
    border-bottom: none;
}
.scan-result-activity-label {
    color: rgba(14, 31, 20, 0.65);
    flex-shrink: 0;
}
.scan-result-activity-value {
    color: var(--forest);
    font-weight: 500;
    text-align: right;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.scan-result-activity-value.is-muted {
    color: rgba(14, 31, 20, 0.4);
    font-weight: 400;
    font-style: italic;
}
.scan-result-actions {
    padding: 16px 24px 24px;
    display: flex;
    gap: 8px;
}
.scan-result-actions .btn { flex: 1; }

/* Temp password modal ------------------------------------------------- */
.temp-pw-display {
    background: var(--paper);
    border: 1px solid var(--paper-3);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    margin: 16px 0;
}
.temp-pw-display code {
    font-family: 'Menlo', 'Monaco', monospace;
    font-size: 22px;
    letter-spacing: 0.1em;
    color: var(--forest);
    font-weight: 600;
}

/* Mobile tweaks ------------------------------------------------------- */
@media (max-width: 600px) {
    .detail-grid {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .detail-grid dt {
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }
    .detail-actions {
        flex-direction: column;
    }
    .detail-actions .btn { flex: none; }
}
