/* Beers & Lunch - app.css */
/* Palette: near-neutral with slate undertone, subtle amber accent */

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

:root {
    --bg:         #1a1c1e;
    --surface:    #23262a;
    --surface-2:  #2c3036;
    --border:     #363b42;
    --text:       #d8dde3;
    --text-dim:   #7a8390;
    --text-faint: #4a5260;
    --accent:     #c8a96e;
    --accent-dim: #8a7248;

    /* Overdue levels - restrained, not garish */
    --warn-bg:    #272318;
    --warn-line:  #6b5a2a;
    --flag-bg:    #291e18;
    --flag-line:  #7a4020;
    --urgent-bg:  #2a1818;
    --urgent-line:#8a2828;
    --never-bg:   #1e2228;
    --never-line: #3a4a60;

    --radius:     6px;
    --font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --mono:       'SF Mono', 'Fira Code', monospace;
    --bottom-nav-h: 56px;
}

html { font-size: 16px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    padding-bottom: calc(var(--bottom-nav-h) + 8px);
}

a { color: inherit; text-decoration: none; }

/* -- Header -- */
.app-header {
    position: sticky; top: 0; z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.header-inner {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 12px;
    height: 52px;
    max-width: 680px; margin: 0 auto;
    gap: 8px;
}
.app-name {
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--accent);
    text-transform: uppercase;
    flex-shrink: 0;
}
.header-nav { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.nav-link { font-size: 0.8rem; color: var(--text-dim); }
.back-link { font-size: 0.85rem; color: var(--text-dim); }
.header-nav .btn { padding: 6px 10px; font-size: 0.78rem; }
@media (max-width: 400px) {
    .header-nav .btn { padding: 5px 8px; font-size: 0.72rem; }
    .app-name { font-size: 0.78rem; }
}

/* -- Main -- */
.main {
    max-width: 680px; margin: 0 auto;
    padding: 16px 16px 0;
}

/* -- Buttons -- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 7px 14px;
    border-radius: var(--radius);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s;
    white-space: nowrap;
}
.btn:active { opacity: 0.75; }
.btn-primary { background: var(--accent); color: #1a1410; }
.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
}
.btn-full { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }

/* -- Stats row -- */
.stats-row {
    display: flex; gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
}
.stat {
    flex: 1;
    display: flex; flex-direction: column; align-items: center;
    padding: 12px 8px;
    background: var(--surface);
    gap: 2px;
}
.stat-num {
    font-size: 1.4rem; font-weight: 700;
    color: var(--text);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.stat-label { font-size: 0.7rem; color: var(--text-dim); text-align: center; }

/* -- Toolbar -- */
.sticky-controls {
    position: sticky;
    top: 52px;
    z-index: 90;
    background: var(--bg);
    padding-bottom: 4px;
}
.toolbar {
    padding: 10px 0 4px;
    margin-bottom: 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.filter-group, .sort-group {
    display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.sort-label { font-size: 0.75rem; color: var(--text-faint); }
.filter-pill, .sort-pill {
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    color: var(--text-dim);
    background: transparent;
    transition: all 0.15s;
}
.filter-pill.active, .sort-pill.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #1a1410;
    font-weight: 600;
}

/* -- Places list -- */
.places-list { display: flex; flex-direction: column; gap: 1px; }

.place-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px;
    background: var(--surface);
    border-left: 3px solid transparent;
    border-radius: var(--radius);
    gap: 12px;
    transition: background 0.15s;
}
.place-row:active { background: var(--surface-2); }

.place-row.level-warn  { background: var(--warn-bg);   border-left-color: var(--warn-line); }
.place-row.level-flag  { background: var(--flag-bg);   border-left-color: var(--flag-line); }
.place-row.level-urgent{ background: var(--urgent-bg); border-left-color: var(--urgent-line);}
.place-row.level-never { background: var(--never-bg);  border-left-color: var(--never-line); }

.place-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.place-name { font-size: 0.95rem; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.place-meta { font-size: 0.72rem; color: var(--text-dim); }

.place-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.place-since { font-size: 0.75rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.place-since.never { color: var(--never-line); }
.place-visits { font-size: 0.68rem; color: var(--text-faint); }

/* -- Legend -- */
.legend {
    display: flex; gap: 12px; flex-wrap: wrap;
    margin-top: 14px; padding: 10px 0;
    border-top: 1px solid var(--border);
}
.legend-item {
    font-size: 0.7rem; color: var(--text-dim);
    padding: 3px 8px; border-radius: 3px;
}
.legend-item.level-warn   { background: var(--warn-bg);   border-left: 2px solid var(--warn-line); }
.legend-item.level-flag   { background: var(--flag-bg);   border-left: 2px solid var(--flag-line); }
.legend-item.level-urgent { background: var(--urgent-bg); border-left: 2px solid var(--urgent-line); }
.legend-item.level-never  { background: var(--never-bg);  border-left: 2px solid var(--never-line); }

/* -- Outings list -- */
.page-heading { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.count-badge {
    font-size: 0.72rem; color: var(--text-dim);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 100px; padding: 1px 7px;
}
.outings-list { display: flex; flex-direction: column; gap: 1px; }
.outing-row {
    display: flex; gap: 12px;
    padding: 12px 14px;
    background: var(--surface);
    border-radius: var(--radius);
    transition: background 0.15s;
}
.outing-row:active { background: var(--surface-2); }
.outing-left { display: flex; flex-direction: column; gap: 3px; flex-shrink: 0; min-width: 90px; }
.outing-date { font-size: 0.82rem; color: var(--text); font-weight: 500; }
.outing-vibe { font-size: 0.68rem; color: var(--text-dim); }
.outing-right { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.outing-places { font-size: 0.82rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.outing-notes { font-size: 0.72rem; color: var(--text-faint); }

/* -- Forms -- */
.form-section { margin-bottom: 24px; }
.section-title { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 12px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 0.78rem; color: var(--text-dim); }
.field input[type="text"],
.field input[type="url"],
.field input[type="date"],
.field input[type="password"],
.field select,
.field textarea {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.9rem;
    padding: 9px 12px;
    width: 100%;
    outline: none;
    -webkit-appearance: none;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--accent-dim);
}
.field textarea { resize: vertical; }
.field-inline { flex-direction: row; align-items: center; gap: 8px; }
.field-inline label { font-size: 0.88rem; color: var(--text); }

/* Place checkboxes */
.place-checkboxes { display: flex; flex-direction: column; gap: 1px; }
.check-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.1s;
}
.check-row input[type="checkbox"] { flex-shrink: 0; accent-color: var(--accent); width: 16px; height: 16px; }
.check-row.checked { border-color: var(--accent-dim); background: #231f14; }
.check-name { font-size: 0.9rem; flex: 1; }
.check-meta { font-size: 0.7rem; color: var(--text-dim); flex-shrink: 0; }

.form-actions { display: flex; gap: 10px; padding-top: 4px; }

/* Visit history */
.visits-list { display: flex; flex-direction: column; gap: 1px; }
.visit-row {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px;
    padding: 10px 14px;
    background: var(--surface);
    border-radius: var(--radius);
}
.visit-date { font-size: 0.85rem; font-weight: 500; }
.visit-vibe { font-size: 0.72rem; color: var(--text-dim); }
.visit-notes { font-size: 0.78rem; color: var(--text-faint); width: 100%; }

/* -- Login page -- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.login-wrap { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 20px; }
.login-title { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.04em; color: var(--accent); text-align: center; text-transform: uppercase; }
.login-form { display: flex; flex-direction: column; gap: 14px; }

/* -- Alerts -- */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 0.82rem; margin-bottom: 14px; }
.alert-error { background: var(--urgent-bg); border: 1px solid var(--urgent-line); color: #e8a0a0; }
.alert-success { background: #182218; border: 1px solid #2a4a2a; color: #90c890; }
.form-error { font-size: 0.82rem; color: #e8a0a0; }

/* -- Empty state -- */
.empty-state { padding: 32px 16px; text-align: center; color: var(--text-dim); font-size: 0.88rem; }
.empty-state a { color: var(--accent); }

/* -- Pagination -- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 16px 0; }
.page-info { font-size: 0.78rem; color: var(--text-dim); }

/* -- Bottom nav -- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-around;
    z-index: 100;
}
.bottom-nav-item {
    display: flex; align-items: center; justify-content: center;
    font-size: 0.78rem; color: var(--text-dim);
    flex: 1; height: 100%;
    letter-spacing: 0.02em;
}
.bottom-nav-item.active { color: var(--accent); font-weight: 600; }
.bottom-nav-item.cta {
    color: var(--accent);
    font-weight: 700;
    font-size: 0.85rem;
}

/* -- Responsive tweaks -- */
@media (min-width: 540px) {
    .outing-row { align-items: flex-start; }
}

/* -- Settings / Outing Types -- */
.types-list { display: flex; flex-direction: column; gap: 1px; margin-bottom: 16px; }
.type-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    background: var(--surface);
    border-radius: var(--radius);
    cursor: grab;
}
.type-drag { color: var(--text-faint); font-size: 1.1rem; cursor: grab; flex-shrink: 0; }
.type-name { flex: 1; font-size: 0.9rem; }
.type-count { font-size: 0.72rem; color: var(--text-dim); flex-shrink: 0; }
.type-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-danger { color: #e88080; border-color: #5a2828; }
.btn-disabled { color: var(--text-faint); border-color: var(--border); cursor: not-allowed; opacity: 0.5; }

/* -- Place Picker -- */
.picker-chips {
    display: flex; flex-wrap: wrap; gap: 6px;
    min-height: 0;
    margin-bottom: 6px;
}
.picker-chip {
    display: inline-flex; align-items: center; gap: 5px;
    background: #231f14;
    border: 1px solid var(--accent-dim);
    border-radius: 100px;
    padding: 4px 10px 4px 12px;
    font-size: 0.8rem;
    color: var(--accent);
}
.picker-chip button {
    background: none; border: none; cursor: pointer;
    color: var(--accent-dim); font-size: 1rem; line-height: 1;
    padding: 0; display: flex; align-items: center;
}
.picker-chip button:hover { color: var(--accent); }

.picker-input-wrap {
    position: relative;
}
.picker-search {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.9rem;
    padding: 9px 12px;
    width: 100%;
    outline: none;
    -webkit-appearance: none;
}
.picker-search:focus { border-color: var(--accent-dim); }

.picker-dropdown {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 3px;
    max-height: 220px;
    overflow-y: auto;
    position: relative;
    z-index: 50;
}
.picker-option {
    display: flex; flex-direction: column; gap: 1px;
    padding: 9px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}
.picker-option:last-child { border-bottom: none; }
.picker-option:hover { background: var(--surface); }
.picker-opt-name { font-size: 0.88rem; color: var(--text); }
.picker-opt-meta { font-size: 0.7rem; color: var(--text-dim); }
.picker-more {
    padding: 8px 12px;
    font-size: 0.72rem;
    color: var(--text-faint);
    text-align: center;
    font-style: italic;
}

/* -- Tag checkboxes (place form) -- */
.tag-checkboxes {
    display: flex; flex-wrap: wrap; gap: 8px;
}
.tag-check {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px;
    border-radius: 100px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 0.82rem;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.15s;
}
.tag-check input[type="checkbox"] { display: none; }
.tag-check.checked, .tag-check:has(input:checked) {
    background: #231f14;
    border-color: var(--accent-dim);
    color: var(--accent);
}

/* -- Detail header with back link + action buttons -- */
.header-inner .back-link {
    font-size: 0.8rem;
    color: var(--text-dim);
    white-space: nowrap;
}
@media (max-width: 420px) {
    .header-nav .btn { padding: 6px 10px; font-size: 0.76rem; }
}

/* -- Delete confirmation page -- */
.delete-confirm-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 4px;
}
.delete-place-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}
.delete-meta {
    font-size: 0.78rem;
    color: var(--text-dim);
}
.delete-warning {
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-top: 12px;
}
.btn-danger-solid {
    background: #7a2828;
    color: #f0c0c0;
    border: none;
}
.btn-danger-solid:hover { background: #8a3030; }

/* -- Places search bar -- */
.search-bar {
    position: relative;
    margin-bottom: 10px;
}
.search-bar input {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.9rem;
    padding: 9px 36px 9px 12px;
    width: 100%;
    outline: none;
    -webkit-appearance: none;
}
.search-bar input:focus { border-color: var(--accent-dim); }
#place-search-clear {
    position: absolute; right: 10px; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    color: var(--text-dim); font-size: 1.1rem;
    cursor: pointer; padding: 0; line-height: 1;
}
#place-search-clear:hover { color: var(--text); }
.place-row.search-hidden { display: none; }
.search-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.88rem;
    display: none;
}

/* -- Lazy loading -- */
.place-row.lazy-hidden { display: none; }

/* -- Multi-tag filter -- */
.place-row.tag-hidden { display: none; }
.filter-pill { cursor: pointer; }

/* -- Sort pills as buttons -- */
.sort-pill { cursor: pointer; background: transparent; }

/* -- Two-section places layout -- */
.section-heading {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px; flex-wrap: wrap; gap: 8px;
}
.section-label {
    font-size: 0.78rem; font-weight: 600;
    letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--text-dim);
    display: flex; align-items: center; gap: 6px;
}
.section-heading .legend {
    border-top: none; padding: 0; margin: 0;
}

/* -- Collapsible filter panel -- */
.toolbar-row {
    display: flex; align-items: center; gap: 10px;
    justify-content: space-between;
}
.filter-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 0.82rem; font-weight: 500;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.15s;
}
.filter-toggle.active {
    background: #231f14;
    border-color: var(--accent-dim);
    color: var(--accent);
}
.filter-badge {
    background: var(--accent);
    color: #1a1410;
    font-size: 0.68rem;
    font-weight: 700;
    border-radius: 100px;
    padding: 1px 6px;
    min-width: 18px;
    text-align: center;
}
.filter-panel {
    margin-top: 12px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.filter-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px;
}
.filter-group-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dim);
}
.filter-clear {
    font-size: 0.75rem;
    color: var(--accent);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}
.filter-clear:hover { text-decoration: underline; }
