/* Shelf Audit — mobile-first styles */

:root {
    /* Aisle Eye palette — greens from img/aisle_eye.png (see header_background.css) */
    --brand: #3f9c22;
    --brand-dark: #226310;
    --brand-light: #edf7e3;
    --text: #1a1a1a;
    --text-sub: #666;
    --bg: #f5f5f4;
    --card: #fff;
    --done: #0a7a3d;
    --error: #b3261e;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
}

/* Layout on top of #header from img/header_background.css (Aisle Eye green gradient) */
header#header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px 0 10px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-logo {
    height: 46px;
    width: auto;
    flex-shrink: 0;
    border-radius: 10px;
}

.header-text { min-width: 0; }

/* Small screens: the logo is nearly full-width, so let the title wrap
   underneath it instead of being pushed off the right edge */
@media (max-width: 600px) {
    header#header {
        flex-wrap: wrap;
        height: auto;
        min-height: 70px;
        padding-bottom: 10px;
    }
    .header-logo { height: 38px; }
    .header-text { padding-left: 4px; }
}

header h1 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

#store-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.88);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

main {
    padding: 16px;
    max-width: 640px;
    margin: 0 auto;
}

h2 {
    font-size: 1rem;
    color: var(--text-sub);
    font-weight: 600;
}

.card-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.tappable { cursor: pointer; }
.tappable:active { background: var(--brand-light); }

.card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.card-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.card-sub {
    font-size: 0.8rem;
    color: var(--text-sub);
}

.status-icon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid #ccc;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: #fff;
}

.card.done .status-icon {
    background: var(--done);
    border-color: var(--done);
}

.card.done .card-title { color: var(--text-sub); }

.chevron { flex-shrink: 0; }

#progress-wrap { margin-bottom: 14px; }

#progress-bar {
    height: 8px;
    background: #ddd;
    border-radius: 4px;
    overflow: hidden;
}

#progress-fill {
    height: 100%;
    width: 0;
    background: var(--brand);
    transition: width 0.3s ease;
}

#progress-text {
    font-size: 0.8rem;
    color: var(--text-sub);
    margin-top: 6px;
}

button.primary {
    width: 100%;
    margin-top: 16px;
    padding: 14px;
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

button.primary:active { opacity: 0.85; }

#toast {
    position: fixed;
    bottom: max(env(safe-area-inset-bottom), 16px);
    left: 50%;
    transform: translateX(-50%);
    background: #323232;
    color: #fff;
    padding: 10px 18px;
    border-radius: 20px;
    font-size: 0.85rem;
    max-width: 90vw;
    text-align: center;
    z-index: 20;
}

#toast.error { background: var(--error); }

.chip {
    flex-shrink: 0;
    background: var(--brand-light);
    color: var(--brand);
    border: 1px solid var(--brand);
    border-radius: 14px;
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

/* Urgency group headings (D19b) */
.group-head {
    list-style: none;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-sub);
    padding: 14px 4px 6px;
}

.chip.fix {
    background: #fff3cd;
    color: #7a5200;
    border-color: #b26a00;
}

/* Last week's unfinished fixes card (D19a) */
.prev-fixes-card {
    background: #fff8e6;
    border-left: 3px solid #b26a00;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 14px;
    font-size: 0.88rem;
}
.prev-fixes-sub { color: var(--text-sub); font-size: 0.8rem; display: block; margin-top: 2px; }
.prev-fixes-card ul { list-style: none; margin: 8px 0 0; padding: 0; }
.prev-fixes-card li { padding: 5px 0; border-bottom: 1px solid #f3e9d0; }
.prev-fixes-card li:last-child { border-bottom: none; }
.prev-fixes-card a { color: var(--text); font-weight: 600; text-decoration: none; }
.prev-fixes-card small { color: var(--text-sub); }

/* Fix list (D19) */
.fix-progress { font-size: 0.85rem; color: var(--text-sub); margin: 4px 0 10px; }

.task-list { list-style: none; margin: 0; padding: 0; }

.task {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 6px;
    border-bottom: 1px solid #eee;
}

.task-tick {
    flex-shrink: 0;
    font-size: 1.4rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
}

.task-body { display: flex; flex-direction: column; min-width: 0; }
.task-title { font-weight: 600; }
.task-note { font-size: 0.8rem; color: var(--text-sub); margin-top: 2px; }

.task-done .task-title { text-decoration: line-through; color: var(--text-sub); font-weight: 400; }
.task-focus { background: var(--brand-light); border-radius: 8px; }

.fix-banner {
    margin-top: 14px;
    padding: 12px 14px;
    background: var(--brand-light);
    border-left: 3px solid var(--brand);
    border-radius: 8px;
    font-size: 0.9rem;
}
.fix-banner-actions { margin-top: 10px; display: flex; gap: 10px; }

.chip.analysing {
    background: #f0f0ef;
    color: var(--text-sub);
    border-color: #ccc;
    cursor: default;
    animation: chip-pulse 1.4s ease-in-out infinite;
}

@keyframes chip-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

#findings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 30;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

/* The hidden attribute must beat the display:flex above */
#findings-overlay[hidden] { display: none; }

#findings-panel {
    background: var(--card);
    border-radius: 16px 16px 0 0;
    max-width: 640px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 20px 16px max(env(safe-area-inset-bottom), 20px);
    position: relative;
}

#findings-panel h3 {
    margin: 0 32px 10px 0;
    font-size: 1rem;
}

#findings-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--bg);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1rem;
    cursor: pointer;
}

.findings-summary {
    background: var(--brand-light);
    border-left: 3px solid var(--brand);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.finding-list {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.finding {
    border: 1px solid #e5e5e3;
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.finding-type { font-weight: 600; font-size: 0.85rem; }
.finding-product { font-size: 0.9rem; }
.finding-note { font-size: 0.8rem; color: var(--text-sub); }

.findings-footer {
    margin: 14px 0 0;
    font-size: 0.8rem;
    color: var(--text-sub);
    text-align: center;
}

.tab-bar {
    display: flex;
    gap: 6px;
    border-bottom: 2px solid #e5e5e3;
    margin-bottom: 12px;
}

.tab {
    background: none;
    border: none;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-sub);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.tab.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
}

.review-photo {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 10px;
}

.tab-hint {
    font-size: 0.8rem;
    color: var(--text-sub);
}

.tab-hint a { color: var(--brand); }

.planogram-frame {
    width: 100%;
    height: 60vh;
    border: 1px solid #e5e5e3;
    border-radius: 8px;
}

.brand-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 20px 16px max(env(safe-area-inset-bottom), 20px);
    font-size: 0.75rem;
    color: var(--text-sub);
}

.brand-footer .brand-name {
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--brand);
}
