/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-dark: #1a1209;
    --bg-card: #2a1f10;
    --bg-input: #3a2c18;
    --text-cream: #f5e6c8;
    --text-muted: #b8a080;
    --gold: #d4a030;
    --gold-bright: #f0c040;
    --amber: #c87828;
    --red: #c0392b;
    --green: #27ae60;
    --bar-bg: #3a2c18;
    --bar-fill: #c87828;
    --bar-gold: #d4a030;
    --radius: 8px;
}

html { font-size: 16px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-cream);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-bright); }

.container { max-width: 900px; margin: 0 auto; padding: 0 1rem; width: 100%; }

/* === Header === */
.site-header {
    background: linear-gradient(180deg, #2a1f10 0%, var(--bg-dark) 100%);
    border-bottom: 2px solid var(--gold);
    padding: 1.5rem 0 1rem;
    text-align: center;
}
.site-header .container { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.logo { font-size: 1.8rem; font-weight: 800; color: var(--gold); letter-spacing: -0.02em; }
.logo:hover { color: var(--gold-bright); }
.tagline { color: var(--text-muted); font-size: 0.9rem; }
.site-header nav { margin-top: 0.5rem; display: flex; gap: 1.5rem; }
.site-header nav a { color: var(--text-cream); font-size: 0.9rem; font-weight: 500; }
.site-header nav a:hover { color: var(--gold); }

/* === Footer === */
.site-footer { margin-top: auto; padding: 2rem 0; text-align: center; color: var(--text-muted); font-size: 0.8rem; border-top: 1px solid var(--bg-card); }
.footer-login { display: inline-block; margin-top: 0.5rem; font-size: 0.8rem; color: var(--text-muted); }
.footer-login:hover { color: var(--gold); }

/* === Messages === */
.messages { margin: 1rem 0; }
.message { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 0.5rem; }
.message.error { background: rgba(192, 57, 43, 0.2); border: 1px solid var(--red); }
.message.success { background: rgba(39, 174, 96, 0.2); border: 1px solid var(--green); }

/* === Buttons === */
.btn {
    display: inline-block; padding: 0.6rem 1.2rem; border-radius: var(--radius);
    font-weight: 600; font-size: 0.9rem; border: none; cursor: pointer;
    text-align: center; transition: background 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--gold); color: var(--bg-dark); }
.btn-primary:hover { background: var(--gold-bright); color: var(--bg-dark); }
.btn-secondary { background: var(--bg-input); color: var(--text-cream); }
.btn-secondary:hover { background: #4a3c28; color: var(--text-cream); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #e74c3c; color: #fff; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* === Rankings Page === */
main.container { padding-top: 2rem; padding-bottom: 2rem; flex: 1; }
h1 { font-size: 1.6rem; margin-bottom: 1.5rem; color: var(--gold); }

.rankings-list { display: flex; flex-direction: column; gap: 1rem; }
.ranking-card {
    display: flex; align-items: center; gap: 1rem;
    background: var(--bg-card); border-radius: var(--radius);
    padding: 1rem; text-decoration: none; color: var(--text-cream);
    transition: background 0.2s, border-color 0.2s;
    border: 1px solid transparent;
}
.ranking-card:hover { background: #352a16; border-color: var(--gold); color: var(--text-cream); }

.rank-number { font-size: 1.6rem; font-weight: 800; color: var(--gold); min-width: 2.5rem; text-align: center; }
.ranking-photo { width: 80px; height: 80px; border-radius: var(--radius); overflow: hidden; flex-shrink: 0; }
.ranking-photo img { width: 100%; height: 100%; object-fit: cover; }
.no-photo { width: 100%; height: 100%; background: var(--bg-input); display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 0.7rem; }

.ranking-info { flex: 1; }
.ranking-info h2 { font-size: 1.1rem; margin-bottom: 0.15rem; }
.neighborhood { color: var(--text-muted); font-size: 0.85rem; }

.overall-score {
    display: inline-block; font-size: 1.3rem; font-weight: 800;
    padding: 0.15rem 0.6rem; border-radius: var(--radius);
    background: var(--bg-input); margin: 0.25rem 0;
}
.score-gold { color: var(--gold-bright); background: rgba(212, 160, 48, 0.15); }
.score-silver { color: var(--text-cream); }

.score-bars-mini { margin-top: 0.4rem; }
.mini-bar { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.2rem; }
.mini-label { font-size: 0.7rem; color: var(--text-muted); min-width: 55px; }
.bar-track { flex: 1; height: 6px; background: var(--bar-bg); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--bar-fill); border-radius: 3px; transition: width 0.3s; }
.bar-gold { background: var(--bar-gold); }

/* === Detail Page === */
.detail-header { margin-bottom: 2rem; }
.back-link { display: inline-block; margin-bottom: 1rem; font-size: 0.85rem; color: var(--text-muted); }
.back-link:hover { color: var(--gold); }
.detail-header h1 { margin-bottom: 0.25rem; font-size: 2rem; }
.address, .website, .visit-date { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 0.15rem; }

.detail-scores { display: flex; gap: 2rem; align-items: flex-start; margin-bottom: 2rem; flex-wrap: wrap; }
.overall-score-large {
    text-align: center; padding: 1.5rem; border-radius: var(--radius);
    background: var(--bg-card); min-width: 100px;
}
.score-value { display: block; font-size: 2.5rem; font-weight: 800; }
.score-label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }
.overall-score-large.score-gold .score-value { color: var(--gold-bright); }

.score-breakdown { flex: 1; min-width: 250px; }
.score-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.6rem; }
.score-name { min-width: 80px; font-size: 0.9rem; font-weight: 500; }
.score-row .bar-track { flex: 1; height: 10px; }
.score-row .bar-fill { height: 100%; }
.score-num { min-width: 30px; text-align: right; font-weight: 700; font-size: 0.95rem; }

.detail-notes { margin-bottom: 2rem; }
.detail-notes h2 { font-size: 1.2rem; margin-bottom: 0.75rem; color: var(--gold); }

/* === Photo Grid === */
.detail-photos h2 { font-size: 1.2rem; margin-bottom: 0.75rem; color: var(--gold); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.75rem; }
.photo-item { cursor: pointer; border-radius: var(--radius); overflow: hidden; position: relative; }
.photo-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; transition: transform 0.2s; }
.photo-item:hover img { transform: scale(1.03); }
.photo-caption { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.7); color: #fff; padding: 0.3rem 0.5rem; font-size: 0.75rem; }

/* === Lightbox === */
.lightbox {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.92);
    z-index: 1000; align-items: center; justify-content: center;
}
.lightbox.active { display: flex; }
.lightbox-close {
    position: absolute; top: 1rem; right: 1rem;
    font-size: 2rem; color: #fff; background: none; border: none; cursor: pointer;
}
.lightbox-img { max-width: 90vw; max-height: 90vh; border-radius: var(--radius); }

/* === Auth Form === */
.auth-form { max-width: 360px; margin: 3rem auto; background: var(--bg-card); padding: 2rem; border-radius: var(--radius); }
.auth-form h1 { text-align: center; margin-bottom: 1.5rem; }

/* === Forms === */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; color: var(--text-muted); }
.form-input {
    width: 100%; padding: 0.6rem 0.8rem; border: 1px solid #4a3c28;
    border-radius: var(--radius); background: var(--bg-input); color: var(--text-cream);
    font-size: 0.95rem;
}
.form-input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px rgba(212, 160, 48, 0.2); }
textarea.form-input { resize: vertical; }
.form-checkbox { width: auto; }
.field-error { color: var(--red); font-size: 0.8rem; display: block; margin-top: 0.2rem; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }
.form-actions { margin-top: 1.5rem; display: flex; gap: 0.75rem; }

fieldset { border: 1px solid #4a3c28; border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.5rem; }
legend { color: var(--gold); font-weight: 700; padding: 0 0.5rem; font-size: 1rem; }

/* === Scores Grid === */
.scores-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.score-group { position: relative; }

/* === Calibration Panel === */
.calibration-panel {
    margin-top: 0.5rem; background: var(--bg-dark); border: 1px solid #4a3c28;
    border-radius: var(--radius); padding: 0.5rem; font-size: 0.8rem;
    display: none; max-height: 200px; overflow-y: auto;
}
.calibration-panel.visible { display: block; }
.cal-item { display: flex; justify-content: space-between; padding: 0.2rem 0.4rem; border-radius: 4px; }
.cal-item.this-spot { background: rgba(212, 160, 48, 0.25); color: var(--gold-bright); font-weight: 700; }
.cal-item .cal-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 70%; }
.cal-item .cal-score { font-weight: 600; }

/* === Manage Pages === */
.manage-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.5rem; }
.manage-list { display: flex; flex-direction: column; gap: 0.75rem; }
.manage-card {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--bg-card); padding: 1rem; border-radius: var(--radius);
    flex-wrap: wrap; gap: 0.5rem;
}
.manage-info h2 { font-size: 1rem; }
.manage-actions { display: flex; gap: 0.5rem; align-items: center; }
.inline-form { display: inline; }

/* === Photo Manage === */
.photo-upload-form { background: var(--bg-card); padding: 1.25rem; border-radius: var(--radius); margin-bottom: 1.5rem; }
.photo-upload-form .form-row { flex-wrap: wrap; align-items: flex-end; }
.checkbox-group { display: flex; align-items: center; gap: 0.5rem; }
.checkbox-group label { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0; }

.photo-manage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.75rem; }
.photo-manage-item {
    background: var(--bg-card); border-radius: var(--radius); overflow: hidden;
    display: flex; flex-direction: column;
}
.photo-manage-item img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.photo-manage-info { padding: 0.5rem; font-size: 0.8rem; flex: 1; }
.photo-manage-item form { padding: 0.5rem; }
.badge { display: inline-block; background: var(--gold); color: var(--bg-dark); font-size: 0.7rem; font-weight: 700; padding: 0.1rem 0.4rem; border-radius: 4px; }

/* === Empty State === */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state a { color: var(--gold); }

/* === Confirm Delete === */
.confirm-delete { max-width: 480px; margin: 3rem auto; background: var(--bg-card); padding: 2rem; border-radius: var(--radius); text-align: center; }
.confirm-delete h1 { font-size: 1.3rem; margin-bottom: 1rem; }
.confirm-delete p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* === Responsive === */
@media (max-width: 600px) {
    .ranking-card { flex-wrap: wrap; }
    .ranking-photo { width: 60px; height: 60px; }
    .detail-scores { flex-direction: column; }
    .form-row { flex-direction: column; gap: 0; }
    .scores-grid { grid-template-columns: 1fr; }
    .manage-card { flex-direction: column; align-items: flex-start; }
    .photo-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
