/* Cave a Vin - Mobile-first dark theme */

:root {
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-card-hover: #222240;
    --bg-input: #16213e;
    --text: #e0e0e0;
    --text-muted: #888;
    --text-light: #aaa;
    --accent: #6c5ce7;
    --accent-light: #a29bfe;
    --red: #e74c3c;
    --red-bg: #2d1a1a;
    --orange: #f39c12;
    --orange-bg: #2d2a1a;
    --green: #27ae60;
    --green-bg: #1a2d1a;
    --border: #2a2a3e;
    --radius: 12px;
    --nav-height: 64px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding-bottom: var(--nav-height);
    -webkit-font-smoothing: antialiased;
}

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

/* Container */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
}

/* Bottom nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    color: var(--text-muted);
    padding: 6px 12px;
    transition: color 0.2s;
}

.nav-item.active { color: var(--accent-light); }
.nav-icon { font-size: 22px; }
.nav-scan .nav-icon {
    background: var(--accent);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: -10px;
}

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}
.page-header h1 { font-size: 22px; flex: 1; }
.back-link { color: var(--accent-light); font-size: 14px; white-space: nowrap; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}
.btn:hover { background: var(--bg-card-hover); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-light); }
.btn-secondary { background: var(--bg-input); border: 1px solid var(--border); }
.btn-danger { background: var(--red); color: white; }
.btn-warning { background: var(--orange); color: #111; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-block { width: 100%; }

/* Flash messages */
.flash-container {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    width: 90%;
    max-width: 500px;
}
.flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    transition: opacity 0.3s;
}
.flash-success { background: var(--green-bg); border: 1px solid var(--green); }
.flash-error { background: var(--red-bg); border: 1px solid var(--red); }

/* KPI grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.kpi-small { grid-template-columns: repeat(3, 1fr); }
.kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}
.kpi-value { font-size: 28px; font-weight: 700; color: var(--accent-light); }
.kpi-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.kpi-link { text-decoration: none; transition: background 0.2s; cursor: pointer; }
.kpi-link:hover { background: var(--bg-card-hover); }

/* Sections */
.section { margin-bottom: 24px; }
.section h2 { font-size: 16px; margin-bottom: 12px; color: var(--text-light); }

/* Apogee bars */
.apogee-bars {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.apogee-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 8px;
    border-radius: var(--radius);
    text-decoration: none;
}
.apogee-past { background: var(--red-bg); border: 1px solid var(--red); }
.apogee-now { background: var(--orange-bg); border: 1px solid var(--orange); }
.apogee-garde { background: var(--green-bg); border: 1px solid var(--green); }
.apogee-count { font-size: 28px; font-weight: 700; }
.apogee-past .apogee-count { color: var(--red); }
.apogee-now .apogee-count { color: var(--orange); }
.apogee-garde .apogee-count { color: var(--green); }
.apogee-label { font-size: 11px; color: var(--text-muted); }

/* Bar chart */
.bar-chart { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: flex; align-items: center; gap: 8px; }
.bar-link { text-decoration: none; border-radius: 6px; padding: 4px 6px; margin: -4px -6px; transition: background 0.2s; cursor: pointer; }
.bar-link:hover { background: var(--bg-card-hover); }
.bar-label { width: 120px; font-size: 12px; text-align: right; color: var(--text-light); flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 20px; background: var(--bg-input); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; min-width: 2px; transition: width 0.5s; }
.bar-value { width: 30px; font-size: 12px; color: var(--text-muted); }

/* Color-specific fills */
.color-rouge { background: #8b2252 !important; }
.color-blanc { background: #d4a926 !important; }
.color-rose { background: #e88ca5 !important; }
.color-effervescent { background: #5bb8d4 !important; }
.color-nc { background: #666 !important; }

/* Color dots */
.bottle-color-dot {
    width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
}
.bottle-color-dot-inline {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle;
}
.bottle-color-dot.color-rouge, .bottle-color-dot-inline.color-rouge { background: #8b2252; }
.bottle-color-dot.color-blanc, .bottle-color-dot-inline.color-blanc { background: #d4a926; }
.bottle-color-dot.color-rose, .bottle-color-dot-inline.color-rose { background: #e88ca5; }
.bottle-color-dot.color-effervescent, .bottle-color-dot-inline.color-effervescent { background: #5bb8d4; }
.bottle-color-dot.color-nc, .bottle-color-dot-inline.color-nc { background: #666; }

/* Millesime chart */
.millesime-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 8px;
}
.mill-col { display: flex; flex-direction: column; align-items: center; min-width: 32px; text-decoration: none; color: inherit; }
.mill-link { border-radius: 6px; padding: 4px 2px; transition: background 0.2s; cursor: pointer; }
.mill-link:hover { background: var(--bg-card-hover); }
.mill-bar {
    width: 24px;
    background: var(--accent);
    border-radius: 4px 4px 0 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 4px;
}
.mill-count { font-size: 10px; margin-top: -16px; color: var(--accent-light); }
.mill-year { font-size: 9px; color: var(--text-muted); margin-top: 4px; writing-mode: vertical-rl; }

/* Search bar */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.search-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 14px;
    outline: none;
}
.search-input:focus { border-color: var(--accent); }

/* Filters */
.filters {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.filters select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 12px;
    outline: none;
    flex: 1;
    min-width: 0;
}
.filter-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.results-count { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }

/* Bottle cards */
.bottle-list { display: flex; flex-direction: column; gap: 8px; }

.bottle-card {
    display: block;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    border: 1px solid var(--border);
    transition: background 0.2s;
    position: relative;
}
.bottle-card:hover { background: var(--bg-card-hover); }
.bottle-empty { opacity: 0.5; }
.bottle-alert-past { border-left: 3px solid var(--red); }
.bottle-alert-now { border-left: 3px solid var(--orange); }
.bottle-alert-garde { border-left: 3px solid var(--green); }

.bottle-link { display: block; text-decoration: none; color: inherit; }

.bottle-top-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.bottle-name { flex: 1; font-weight: 600; font-size: 15px; }
.bottle-qty { font-size: 14px; color: var(--accent-light); font-weight: 700; background: var(--bg-input); padding: 2px 8px; border-radius: 6px; }
.qty-zero { color: var(--text-muted); background: none; }

.bottle-info-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.bottle-details { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.bottle-appellation { font-size: 13px; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bottle-region-mill { font-size: 11px; color: var(--text-muted); }

.bottle-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.bottle-location {
    display: inline-block;
    background: #2a2a4e;
    color: #8b9cf7;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 6px;
    letter-spacing: 0.5px;
    border: 1px solid #3a3a5e;
}

.bottle-price-row { font-size: 12px; color: var(--accent-light); margin-top: 4px; }

/* Legacy classes kept for alerts/detail pages */
.bottle-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.bottle-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.bottle-footer { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-muted); }

.no-results { text-align: center; color: var(--text-muted); padding: 40px 0; font-size: 16px; }

/* Suggested apogee */
.apogee-suggested { font-size: 10px; opacity: 0.7; }
.apogee-suggested-detail { font-size: 12px; color: var(--text-muted); margin-left: 6px; }

.bottle-price { color: var(--accent-light); }

/* Apogee badges */
.apogee-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.badge-past { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }
.badge-now { background: var(--orange-bg); color: var(--orange); border: 1px solid var(--orange); }
.badge-garde { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }

/* Card action (inline button) */
.card-action {
    position: absolute;
    right: 14px;
    bottom: 14px;
}

/* Alert titles */
.alert-title { font-size: 16px; font-weight: 600; }
.alert-past { color: var(--red); }
.alert-now { color: var(--orange); }
.alert-garde { color: var(--green); }

/* Detail page */
.detail-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
}
.detail-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.detail-header .bottle-color-dot { width: 16px; height: 16px; }
.detail-name { font-size: 20px; font-weight: 700; }
.detail-cuvee { font-size: 14px; color: var(--text-muted); }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}
.detail-full { grid-column: 1 / -1; }
.field-label { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.field-value { font-size: 15px; margin-top: 2px; }
.qty-big { font-size: 24px; font-weight: 700; color: var(--accent-light); }

.detail-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.inline-form { display: inline; }

/* Activity list */
.activity-list { display: flex; flex-direction: column; gap: 4px; }
.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    transition: background 0.2s;
}
.activity-item:hover { background: var(--bg-card); }
.activity-icon { font-size: 20px; flex-shrink: 0; }
.activity-text { font-size: 13px; line-height: 1.4; }
.text-muted { color: var(--text-muted); }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
    font-size: 14px;
}

/* Cave map */
.map-legend {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}
.map-legend h3 { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.legend-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-input);
    border-radius: 6px;
    font-size: 12px;
}
.legend-region { color: var(--text-light); font-weight: 600; }
.legend-rows { color: var(--accent-light); font-weight: 700; }

.zone-markers { display: flex; gap: 12px; margin-bottom: 16px; }
.zone-marker {
    flex: 1;
    text-align: center;
    padding: 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.zone-rouge { background: #2d1a2a; color: #e88; border: 1px solid #8b2252; }
.zone-blanc { background: #2d2a1a; color: #d4a926; border: 1px solid #d4a926; }

.map-row {
    margin-bottom: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}
.map-row-rouge { border-left: 3px solid #8b2252; }
.map-row-blanc { border-left: 3px solid #d4a926; }
.map-row-other { border-left: 3px solid #666; }

.map-row-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-card);
}
.map-row-letter {
    font-size: 24px;
    font-weight: 800;
    color: var(--accent-light);
    width: 32px;
    text-align: center;
}
.map-row-info { font-size: 12px; color: var(--text-muted); flex: 1; }

.map-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px 14px;
    background: var(--bg);
}
.map-slot {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    min-width: 160px;
    flex: 1;
    max-width: 280px;
}
.slot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.slot-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--accent-light);
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 4px;
}
.slot-count { font-size: 12px; color: var(--text-muted); }
.slot-region { font-size: 10px; color: var(--text-muted); margin-top: 6px; text-transform: uppercase; letter-spacing: 0.5px; }

.slot-bottle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 12px;
    text-decoration: none;
    color: inherit;
    border-radius: 4px;
    transition: background 0.15s;
}
.slot-bottle:hover { background: var(--bg-input); padding-left: 4px; padding-right: 4px; }
.slot-no-loc { opacity: 0.7; }
.slot-wine-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.slot-wine-info { color: var(--text-muted); font-size: 11px; }
.slot-wine-qty { color: var(--accent-light); font-weight: 600; font-size: 11px; }

.apogee-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.dot-past { background: var(--red); }
.dot-now { background: var(--orange); }
.dot-garde { background: var(--green); }

/* Forms */
.bottle-form, .scan-result-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    margin-bottom: 16px;
}
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 14px;
    outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.hint { color: var(--accent-light); font-size: 11px; text-transform: none; letter-spacing: 0; }

.scan-result-card h3 { font-size: 16px; margin-bottom: 12px; color: var(--accent-light); }

/* Scan page */
.scan-mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
.scan-mode-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.2s;
}
.scan-mode-card.active { border-color: var(--accent); }
.scan-mode-card input { display: none; }
.scan-mode-icon { font-size: 36px; margin-bottom: 8px; }
.scan-mode-label { font-size: 14px; font-weight: 600; }
.scan-mode-desc { font-size: 11px; color: var(--text-muted); }

.scan-capture { margin-bottom: 16px; }
.scan-capture-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    background: var(--bg-card);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 16px;
    color: var(--text-light);
    transition: border-color 0.2s;
}
.scan-capture-btn:hover { border-color: var(--accent); }
.scan-capture-icon { font-size: 32px; }
.scan-capture input[type="file"] { display: none; }

.scan-preview {
    margin-bottom: 16px;
    text-align: center;
}
.scan-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.scan-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.scan-info {
    margin-top: 24px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
}
.scan-info p { margin-bottom: 8px; }

/* Login page */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 40px 30px;
    width: 100%;
    max-width: 360px;
    text-align: center;
    border: 1px solid var(--border);
}
.login-card h1 { font-size: 28px; margin-bottom: 24px; }
.login-card input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 16px;
    margin-bottom: 16px;
    outline: none;
    text-align: center;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
}

/* Service worker (minimal, no offline) */
