/* StorageOrg — Dark, utilitarian, mobile-first */

:root {
    --bg:           #0f172a;
    --surface:      #1e293b;
    --card:         #1e293b;
    --border:       #334155;
    --accent:       #f59e0b;
    --accent-dark:  #d97706;
    --accent-light: #fef3c7;
    --text:         #f1f5f9;
    --muted:        #94a3b8;
    --danger:       #ef4444;
    --danger-bg:    #450a0a;
    --success:      #10b981;
    --success-bg:   #022c22;
    --radius:       10px;
    --radius-sm:    6px;
    --nav-h:        64px;
    --header-h:     56px;
    --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    min-height: 100dvh;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, button, select { font-family: inherit; font-size: 16px; } /* prevent iOS zoom */
img { display: block; max-width: 100%; }
ul { list-style: none; }

/* ── Accent bar — the signature ── */
body::before {
    content: '';
    display: block;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent);
    z-index: 100;
}

/* ── App header ── */
.app-header {
    position: sticky;
    top: 3px; /* below accent bar */
    z-index: 90;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    height: var(--header-h);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}

.app-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    flex-shrink: 0;
    margin-left: -8px;
    transition: color 0.15s, background 0.15s;
}
.back-btn:active { background: var(--surface); color: var(--text); }

.header-title {
    flex: 1;
    font-size: 17px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: var(--muted);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    transition: color 0.15s;
}
.logout-btn:active { color: var(--text); }

/* ── Main content ── */
.main-content {
    padding-bottom: calc(var(--nav-h) + 16px);
    max-width: 540px;
    margin: 0 auto;
}

/* ── Bottom nav ── */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--nav-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 90;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.02em;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.nav-item:active { color: var(--accent); }
.nav-item--active { color: var(--accent); }

.nav-item--new {
    color: var(--accent);
}
.nav-item--new svg {
    background: var(--accent);
    color: #000;
    border-radius: 50%;
    padding: 3px;
    width: 30px;
    height: 30px;
    stroke: #000;
}

/* ── Flash messages ── */
.flash {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    max-width: 540px;
    margin: 0 auto;
}
.flash--error   { background: var(--danger-bg); color: #fca5a5; border-left: 3px solid var(--danger); }
.flash--success { background: var(--success-bg); color: #6ee7b7; border-left: 3px solid var(--success); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 20px;
    height: 46px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 15px;
    border: none;
    transition: opacity 0.15s, background 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { opacity: 0.75; }
.btn--full { width: 100%; }

.btn--primary  { background: var(--accent); color: #000; }
.btn--accent   { background: var(--accent); color: #000; }
.btn--secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn--danger   { background: var(--danger); color: #fff; }
.btn--ghost    { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn--sm       { height: 34px; font-size: 13px; padding: 0 12px; }

/* ── Form fields ── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.required { color: var(--accent); }

.field-input {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 12px 14px;
    width: 100%;
    outline: none;
    transition: border-color 0.15s;
}
.field-input:focus { border-color: var(--accent); }
.field-input::placeholder { color: var(--muted); }

.field-textarea { resize: vertical; min-height: 80px; }

/* ── Login ── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding: 24px 16px; }

.login-wrap {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 0;
}
.login-app-name { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }

.login-form { display: flex; flex-direction: column; gap: 16px; }

/* ── Dashboard ── */
.stats-bar {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.stat { display: flex; align-items: baseline; gap: 5px; }
.stat-number { font-size: 24px; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-label  { font-size: 13px; color: var(--muted); }
.stat-divider { width: 1px; height: 20px; background: var(--border); margin: 0 20px; }

/* ── Box list (shared: dashboard + search) ── */
.box-list { display: flex; flex-direction: column; }

.box-card {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.1s;
}
.box-card:active { background: var(--surface); }

/* Warehouse-label left accent on active state */
.box-card:active { border-left: 3px solid var(--accent); padding-left: 17px; }

.box-card__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.box-card__name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.box-card__location { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 3px; }

.box-card__meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.box-card__count { font-size: 13px; color: var(--muted); }
.box-card__photos { display: flex; align-items: center; gap: 3px; font-size: 13px; color: var(--muted); }

/* ── Empty state ── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 60px 24px;
    text-align: center;
}
.empty-title { font-size: 18px; font-weight: 600; }
.empty-sub   { font-size: 14px; color: var(--muted); line-height: 1.5; }

/* ── Box detail ── */
.box-detail { display: flex; flex-direction: column; }

/* The label block — the signature element */
.box-label {
    padding: 20px 20px 18px;
    border-bottom: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    margin: 0;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.box-label__name {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--text);
}
.box-label__location {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--accent);
    font-weight: 500;
}
.box-label__desc {
    font-size: 14px;
    color: var(--muted);
    margin-top: 2px;
}
.box-label__guid {
    font-size: 10px;
    color: var(--border);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.05em;
    margin-top: 4px;
    font-family: monospace;
}

/* Photo strip */
.photo-strip {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
}
.photo-strip::-webkit-scrollbar { display: none; }

.photo-item { position: relative; flex-shrink: 0; }

.photo-thumb {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.photo-delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: rgba(0,0,0,0.7);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.photo-delete-form { display: contents; }

/* Add photo */
.add-photo-form { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.photo-upload-label { position: relative; }
.photo-file-input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }

/* Items section */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 8px;
}
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.section-count { font-size: 13px; color: var(--muted); }

/* Add item form */
.add-item-form { padding: 0 16px 12px; border-bottom: 1px solid var(--border); }
.add-item-row { display: flex; gap: 8px; align-items: center; }
.add-item-row .field-input { flex: 1; height: 46px; }
.qty-input { width: 60px; flex: none; text-align: center; }
.add-item-btn { flex-shrink: 0; width: 46px; height: 46px; padding: 0; font-size: 22px; border-radius: var(--radius); }

.empty-items { padding: 24px 16px; color: var(--muted); font-size: 14px; }

/* Item list */
.item-list { display: flex; flex-direction: column; }

.item-row {
    display: flex;
    align-items: center;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    gap: 10px;
}
.item-row__info { flex: 1; min-width: 0; }
.item-row__name { display: block; font-size: 15px; font-weight: 500; }
.item-row__notes { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.item-row__right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.item-row__qty { font-size: 14px; color: var(--accent); font-weight: 600; }

.delete-btn {
    background: none;
    border: none;
    color: var(--muted);
    display: flex;
    align-items: center;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: color 0.15s;
}
.delete-btn:active { color: var(--danger); }

.inline-form { display: contents; }

/* Box actions */
.box-actions { padding: 20px 16px; }

/* ── Form pages (new/edit) ── */
.form-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
}

.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-card--danger {
    border-color: var(--danger);
    background: var(--danger-bg);
}

.danger-title { font-size: 15px; font-weight: 700; color: var(--danger); }
.danger-desc  { font-size: 14px; color: #fca5a5; line-height: 1.4; }

/* GUID block on edit page */
.guid-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.guid-block__label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.guid-block__url   { font-size: 12px; color: var(--accent); word-break: break-all; font-family: monospace; }

/* ── Search page ── */
.search-page { padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.search-form { display: flex; gap: 8px; align-items: center; }
.search-input-wrap { flex: 1; position: relative; }

.search-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.search-input { padding-left: 40px; height: 46px; }
.search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: var(--muted);
    line-height: 1;
    padding: 4px;
}

.search-summary { font-size: 13px; color: var(--muted); }
.search-hint    { font-size: 14px; color: var(--muted); padding: 8px 0; }

.search-page .box-list {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.search-page .box-card:last-child { border-bottom: none; }
