/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
img { max-width: 100%; height: auto; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6; color: #333; background-color: #f5f5f5;
}

#container {
    max-width: 1200px; margin: 0 auto; background-color: #fff;
    min-height: 100vh; display: flex; flex-direction: column;
}

/* ===== Header ===== */
header {
    background: linear-gradient(135deg, #ff6600 0%, #ff8833 100%);
    color: white; padding: 1.5rem; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
#header h1 { font-size: 2rem; margin-bottom: 0.25rem; }
#header h1 a { color: white; text-decoration: none; }
.tagline { font-size: 0.9rem; opacity: 0.9; }

/* ===== Navigation ===== */
nav { background-color: #333; padding: 0; }
nav ul { list-style: none; display: flex; flex-wrap: wrap; }
nav li { flex: 1; min-width: 100px; }
nav a {
    display: block; padding: 1rem; color: white; text-decoration: none;
    text-align: center; transition: background-color 0.2s;
}
nav a:hover { background-color: #555; }

/* ===== Main ===== */
main { flex: 1; padding: 2rem; }

/* ===== Alerts ===== */
.alert { padding: 1rem; margin-bottom: 1.5rem; border-radius: 4px; border-left: 4px solid; }
.alert-success { background-color: #d4edda; border-color: #28a745; color: #155724; }
.alert-info { background-color: #d1ecf1; border-color: #17a2b8; color: #0c5460; }
.alert-error { background-color: #f8d7da; border-color: #dc3545; color: #721c24; }

/* ===== Buttons ===== */
.btn {
    display: inline-block; padding: 0.6rem 1.2rem; background-color: #007bff;
    color: white; text-decoration: none; border-radius: 4px; border: none;
    cursor: pointer; font-size: 1rem; transition: background-color 0.2s;
}
.btn:hover { background-color: #0056b3; }
.btn-primary { background-color: #ff6600; }
.btn-primary:hover { background-color: #cc5200; }
.btn-large { padding: 1rem 2rem; font-size: 1.2rem; }
.btn-small { padding: 0.4rem 0.8rem; font-size: 0.9rem; }
.btn-delete {
    background-color: #dc3545; color: white; border: none;
    padding: 0.25rem 0.5rem; cursor: pointer; border-radius: 4px;
}
.btn-delete:hover { background-color: #c82333; }
.btn-geo {
    background: #f5f5f5; border: 1px solid #ddd; border-radius: 8px;
    font-size: 20px; cursor: pointer; padding: 8px 12px;
}
.btn-geo:hover { background: #eee; }
.btn-geo.loading { animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ===== Forms ===== */
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 500; }
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="date"],
.form-group select {
    width: 100%; padding: 0.75rem; border: 1px solid #ddd;
    border-radius: 4px; font-size: 1rem;
}
.form-group input:focus,
.form-group select:focus { outline: none; border-color: #ff6600; }
.form-group small { display: block; margin-top: 0.25rem; color: #666; font-size: 0.875rem; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }
.form-section { margin-bottom: 2rem; padding-bottom: 2rem; border-bottom: 1px solid #eee; }
.form-section:last-child { border-bottom: none; }
.form-section h3 { margin-bottom: 1rem; color: #ff6600; }
.form-actions { margin-top: 2rem; text-align: center; }

.checkbox-label {
    display: inline-block; margin-right: 1rem;
    margin-bottom: 0.5rem; cursor: pointer;
}
.checkbox-label input { margin-right: 0.25rem; }
.items-checkboxes {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem; margin-bottom: 1rem;
}
.date-inputs { display: flex; gap: 0.5rem; }
.date-inputs select { flex: 1; }

/* ===== Toggle Chips (filters) ===== */
.toggle-group { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.toggle-chip {
    display: inline-flex; align-items: center; padding: 5px 12px;
    border: 1px solid #ccc; border-radius: 20px; font-size: 0.85rem;
    cursor: pointer; user-select: none; background: #fff;
    transition: all 0.15s ease; white-space: nowrap;
}
.toggle-chip input[type="checkbox"] { position: absolute; opacity: 0; pointer-events: none; }
.toggle-chip:hover { border-color: #888; background: #f5f5f5; }
.toggle-chip:has(input:checked) { background: #f97316; color: #fff; border-color: #f97316; }
.toggle-chip-alt:has(input:checked) { background: #059669; border-color: #059669; color: #fff; }
.toggle-days .toggle-chip { min-width: 44px; justify-content: center; }

/* ===== Quick Date Buttons ===== */
.quick-dates { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.btn-quick-date {
    padding: 6px 14px; border: 1px solid #d1d5db; border-radius: 20px;
    background: #fff; cursor: pointer; font-size: 13px; transition: all 0.15s;
}
.btn-quick-date:hover { border-color: #f97316; color: #f97316; }
.btn-quick-date.active { background: #f97316; color: #fff; border-color: #f97316; }

/* ===== Hero Search (homepage) ===== */
.hero-search { text-align: center; padding: 20px 0; }
.hero-search h1 { margin: 0 0 4px; }
.subtitle { color: #666; margin: 0 0 16px; }
.search-bar-row {
    display: flex; gap: 8px; max-width: 700px; margin: 0 auto;
    flex-wrap: wrap; justify-content: center;
}
.search-bar-row input,
.search-bar-row select {
    padding: 10px 12px; border: 1px solid #ddd;
    border-radius: 8px; font-size: 15px;
}
.search-bar-row input[name="zip_code"] { width: 100px; }
.search-bar-row select { width: 160px; }
.search-bar-row input[name="city"] { flex: 1; min-width: 120px; }
.filter-row { max-width: 700px; margin: 10px auto 0; text-align: left; }
.full-width-input {
    width: 100%; padding: 10px 12px; border: 1px solid #ddd;
    border-radius: 8px; font-size: 14px; box-sizing: border-box;
}

/* ===== Stats Grid ===== */
.home-stats { margin-bottom: 3rem; }
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem; margin-top: 1rem;
}
.stat-box {
    background: linear-gradient(135deg, #ff6600 0%, #ff8833 100%);
    color: white; padding: 1.5rem; border-radius: 8px;
    text-align: center; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.stat-box h3 { font-size: 2.5rem; margin-bottom: 0.5rem; }
.stat-box p { font-size: 1rem; opacity: 0.9; }

/* ===== Search Section ===== */
.search-section {
    margin-bottom: 3rem; padding: 2rem;
    background-color: #f9f9f9; border-radius: 8px;
}
.search-form { max-width: 800px; }

/* ===== Weather ===== */
.weather-bar {
    display: flex; gap: 8px; overflow-x: auto; padding: 12px 0;
    max-width: 700px; margin: 0 auto; justify-content: center;
}
.weather-day {
    text-align: center; padding: 8px 12px; border-radius: 10px;
    background: #f9fafb; border: 1px solid #e5e7eb; min-width: 72px; font-size: 13px;
}
.weather-day.rain { background: #fef3c7; border-color: #fde68a; }
.weather-day .icon { font-size: 20px; }
.weather-day .temps { color: #374151; font-weight: 600; }
.weather-day .rain-pct { color: #2563eb; font-size: 11px; }
.form-weather {
    display: flex; gap: 8px; margin-bottom: 12px;
    overflow-x: auto; padding: 4px 0; align-items: center;
}
.form-weather .wd {
    text-align: center; padding: 6px 10px; border-radius: 8px;
    background: #f0fdf4; border: 1px solid #bbf7d0; font-size: 12px; min-width: 60px;
}
.form-weather .wd.bad { background: #fef3c7; border-color: #fde68a; }

/* ===== Results Grid ===== */
.results-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem; margin-top: 1.5rem;
}
.sale-card {
    background-color: white; border: 1px solid #ddd; border-radius: 8px;
    padding: 1.5rem; box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s;
}
.sale-card { overflow: hidden; }
.sale-card:hover { box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
.sale-header {
    display: flex; justify-content: space-between;
    align-items: start; margin-bottom: 1rem;
}
.sale-header h4 { margin: 0; font-size: 1.2rem; }
.sale-header a { color: #ff6600; text-decoration: none; }
.sale-header a:hover { text-decoration: underline; }
.zip {
    background-color: #333; color: white; padding: 0.25rem 0.5rem;
    border-radius: 4px; font-size: 0.9rem;
}
.sale-dates { margin-bottom: 1rem; color: #666; }
.sale-address { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; color: #555; }
.sale-items {
    margin-bottom: 1rem; padding: 0.75rem;
    background-color: #f9f9f9; border-radius: 4px; font-size: 0.9rem;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
    overflow: hidden; word-break: break-word;
}
.sale-distance { font-size: 0.85rem; color: #666; margin-top: 4px; }
.sale-photos {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem; margin-bottom: 1rem;
}
.sale-photos img { width: 100%; height: 80px; object-fit: cover; border-radius: 4px; display: block; }
.more-photos { grid-column: span 3; text-align: center; font-size: 0.9rem; color: #666; }
.sale-footer { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #eee; }
.item-tag-sm {
    display: inline-flex; padding: 2px 8px;
    background: #e8f4fd; color: #1a73e8; border-radius: 12px; font-size: 0.8rem;
    white-space: nowrap;
}

/* ===== Detail Page ===== */
.sale-detail { max-width: 800px; margin: 0 auto; }
.sale-detail .sale-header { margin-bottom: 2rem; }
.sale-detail h2 { font-size: 2rem; color: #333; margin-bottom: 0.5rem; }
.info-section { margin-bottom: 2rem; }
.info-section h3 { font-size: 1.3rem; margin-bottom: 0.5rem; color: #333; }
.dates { font-size: 1.1rem; }
.address { font-size: 1rem; line-height: 1.8; }
.items-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.item-tag {
    display: inline-flex; background-color: #ff6600; color: white;
    padding: 0.5rem 1rem; border-radius: 20px; font-size: 0.9rem;
    white-space: nowrap;
}

/* Detail — AI Items */
.items-grid { display: grid; gap: 10px; margin-top: 8px; }
.item-card {
    background: #f9fafb; border: 1px solid #e5e7eb;
    border-radius: 10px; padding: 14px;
}
.item-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 6px;
}
.item-title { font-weight: 600; }
.item-price {
    background: #ecfdf5; color: #059669; font-weight: 700; font-size: 18px;
    padding: 2px 10px; border-radius: 6px; white-space: nowrap; flex-shrink: 0;
}
.item-desc { color: #6b7280; font-size: 14px; margin: 4px 0; }
.item-meta { display: flex; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.item-condition { background: #f3f4f6; padding: 2px 8px; border-radius: 4px; color: #374151; }
.item-category { background: #e8f4fd; padding: 2px 8px; border-radius: 4px; color: #1a73e8; }
.item-pricing-note {
    margin-top: 6px; font-size: 13px; color: #92400e;
    background: #fffbeb; padding: 4px 8px; border-radius: 4px;
}

/* ===== Photos ===== */
.photos-section { margin-bottom: 2rem; }
.photos-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}
.photos-grid a { display: block; overflow: hidden; border-radius: 8px; }
.photos-grid img {
    width: 100%; height: 200px; object-fit: cover; border-radius: 8px;
    cursor: pointer; transition: transform 0.2s; display: block;
}
.photos-grid img:hover { transform: scale(1.05); }
.photo-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem; margin-bottom: 1rem;
}
.photo-item { position: relative; }
.photo-item img { width: 100%; height: 150px; object-fit: cover; border-radius: 4px; display: block; }
.photo-item .btn-delete {
    position: absolute; top: 0.5rem; right: 0.5rem;
    width: 24px; height: 24px; padding: 0;
    display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.sale-actions { display: flex; gap: 1rem; flex-wrap: wrap; }

/* ===== Popular Cities / States ===== */
.popular-section { margin-bottom: 3rem; }
.cities-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem; margin-top: 1rem;
}
.city-item a {
    display: block; padding: 0.75rem; background-color: #f9f9f9;
    border-radius: 4px; text-decoration: none; color: #333;
    transition: background-color 0.2s;
}
.city-item a:hover { background-color: #ff6600; color: white; }
.city-item .count { color: #666; font-size: 0.9rem; }
.city-item a:hover .count { color: white; }
.states-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.state-link {
    display: inline-block; padding: 6px 14px; background: #f0f0f0;
    border-radius: 20px; color: #333; text-decoration: none; font-size: 0.9rem;
}
.state-link:hover { background: #ff6600; color: #fff; }

/* ===== CTA Section ===== */
.cta-section {
    text-align: center; padding: 3rem 1rem;
    background: linear-gradient(135deg, #ff6600 0%, #ff8833 100%);
    color: white; border-radius: 8px;
}
.cta-section h3 { font-size: 2rem; margin-bottom: 1rem; }
.cta-section p { font-size: 1.1rem; margin-bottom: 1.5rem; }

/* ===== Snap to List (Add page) ===== */
.snap-section { margin-bottom: 24px; }
.snap-dropzone {
    border: 2px dashed #d1d5db; border-radius: 16px; padding: 40px;
    text-align: center; cursor: pointer; background: #fafafa; transition: all 0.2s;
}
.snap-dropzone:hover,
.snap-dropzone.dragover { border-color: #f97316; background: #fff7ed; }
.snap-icon { font-size: 48px; margin-bottom: 8px; }
.snap-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.snap-thumbs img { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; }
.snap-loading { text-align: center; padding: 20px; }
.snap-progress {
    width: 100%; height: 6px; background: #f3f4f6;
    border-radius: 3px; overflow: hidden; margin-bottom: 12px;
}
.snap-progress-bar {
    height: 100%; background: linear-gradient(90deg, #f97316, #fb923c);
    border-radius: 3px; width: 0%; transition: width 0.5s;
}
.snap-divider { text-align: center; margin: 20px 0; color: #9ca3af; position: relative; }
.snap-divider::before {
    content: ''; position: absolute; top: 50%; left: 0; right: 0;
    height: 1px; background: #e5e7eb;
}
.snap-divider span { background: #fff; padding: 0 12px; position: relative; }

/* ===== AI Item Cards (editable on Add page) ===== */
.ai-item-card {
    background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 10px;
    padding: 12px; margin-bottom: 8px; overflow: hidden;
    box-sizing: border-box; max-width: 100%;
}
.ai-edit {
    border: 1px solid #e5e7eb; border-radius: 6px; padding: 6px 8px;
    font-size: 14px; font-family: inherit; background: #fff; box-sizing: border-box;
}
.ai-edit:focus { border-color: #f97316; outline: none; }
.ai-edit-title { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; }
.ai-edit-price {
    width: 60px; flex-shrink: 0; text-align: right;
    font-weight: 700; font-size: 16px;
}
.ai-edit-desc {
    width: 100%; margin-top: 6px; resize: vertical;
    color: #4b5563; box-sizing: border-box;
}
.ai-edit-cond { padding: 6px 8px; flex-shrink: 0; }
.ai-edit-cat { flex: 1; min-width: 0; }
.ai-remove-btn {
    background: none; border: 1px solid #fca5a5; color: #ef4444;
    border-radius: 6px; width: 28px; height: 28px; min-width: 28px;
    flex-shrink: 0; cursor: pointer; font-size: 14px; padding: 0;
    display: flex; align-items: center; justify-content: center;
}
.ai-remove-btn:hover { background: #fef2f2; }
.ai-note {
    font-size: 13px; color: #92400e; background: #fffbeb;
    padding: 4px 8px; border-radius: 4px; margin-top: 6px;
}

/* ===== No Results / Loading ===== */
.no-results { text-align: center; padding: 3rem 1rem; color: #666; }
.no-results p { margin-bottom: 1rem; font-size: 1.1rem; }
.htmx-indicator { display: none; text-align: center; padding: 1rem; color: #666; }
.htmx-request .htmx-indicator { display: block; }

/* ===== Offline Page ===== */
.offline-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 60vh; text-align: center;
}
.offline-content { max-width: 500px; padding: 2rem; }
.offline-content svg { color: #999; margin-bottom: 2rem; }
.offline-content h2 { margin-bottom: 1rem; color: #333; }
.offline-content p { margin-bottom: 1rem; color: #666; }
.offline-actions { margin-top: 2rem; display: flex; gap: 1rem; justify-content: center; }

/* ===== Share Section ===== */
.share-section { margin-bottom: 2rem; }

/* ===== Footer ===== */
footer {
    background-color: #333; color: white; text-align: center;
    padding: 2rem; margin-top: auto;
}
footer p { margin: 0.5rem 0; }
footer a { color: #ff6600; text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    main { padding: 1rem; }
    #header h1 { font-size: 1.5rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { flex-direction: column; }
    .form-row .form-group { min-width: 100%; }
    .results-grid { grid-template-columns: 1fr; }
    .sale-actions { flex-direction: column; }
    .sale-actions .btn { width: 100%; }
    .search-bar-row { flex-direction: column; }
    .search-bar-row input,
    .search-bar-row select { width: 100%; }
}