/* RV Camping Finder — Custom Styles */

/* Leaflet overrides — prevent Pico CSS from styling map elements,
   allow vertical page scroll through map on touch devices */
.leaflet-container,
.leaflet-container * {
    touch-action: pan-y !important;
}

.leaflet-marker-icon,
.leaflet-marker-shadow {
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
}

.leaflet-control-zoom a {
    padding: 0 !important;
    width: 30px !important;
    height: 30px !important;
    line-height: 30px !important;
    font-size: 18px !important;
}

a.leaflet-control-zoom-in {
    border-radius: 4px 4px 0 0 !important;
}

a.leaflet-control-zoom-out {
    border-radius: 0 0 4px 4px !important;
}

/* Nav */
.brand { text-decoration: none; }

/* Search form */
.search-mode-toggle {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.rig-selector {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.tag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.25rem;
}

/* Geolocation */
.geo-locate-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.geo-locate-row button {
    flex-shrink: 0;
    margin: 0;
}

.geo-status {
    font-size: 0.85rem;
    color: var(--pico-muted-color);
}

.geo-success {
    color: #2d7d46;
    font-weight: 500;
}

.geo-error {
    color: #c0392b;
}

/* Results header */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.results-actions {
    display: flex;
    gap: 0.5rem;
}

/* Result cards */
.result-card {
    margin-bottom: 0.75rem;
}

.card-body {
    display: flex;
    gap: 1rem;
}

.card-main {
    flex: 1;
    min-width: 0;
}

.card-photo {
    flex: 0 0 140px;
}

.card-photo img {
    width: 140px;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.card-title {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.card-title a {
    text-decoration: none;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: var(--pico-muted-color);
}

.card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}

.card-stats span {
    background: #edf2f7;
    color: #2c3e50;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.3rem;
}

.card-confidence {
    margin-top: 0.2rem;
}

/* Condition pills */
.condition-pills {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.condition-pill {
    display: inline-block;
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    white-space: nowrap;
}

/* Conditions grid (facility detail) */
.conditions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

.condition-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.condition-label {
    color: var(--pico-muted-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.7rem;
}

.condition-value {
    font-weight: bold;
    font-size: 1.1rem;
}

/* Org badge */
.org-badge {
    background: #34495e;
    color: white;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: bold;
}

.type-label {
    font-style: italic;
}

/* Tags */
.tag {
    display: inline-block;
    background: #edf2f7;
    color: #2c3e50;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.78rem;
}

.tag-warning {
    background: #fde8e8;
    color: #c0392b;
}

.tag-more {
    color: var(--pico-muted-color);
    font-style: italic;
}

.tag-group {
    margin-bottom: 0.5rem;
}

.tag-category {
    display: block;
    color: var(--pico-muted-color);
    margin-bottom: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* NPS limited data notice */
.nps-notice {
    background: #fff8e1;
    border-left: 4px solid #f9a825;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.nps-notice p {
    margin: 0;
    font-size: 0.9rem;
}

/* Seasonal / closure warning notice */
.closure-notice {
    background: #fff8e1;
    border-left: 4px solid #d4782f;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.closure-notice-red {
    background: #fde8e8;
    border-left-color: #c0392b;
}

.closure-notice p {
    margin: 0;
    font-size: 0.9rem;
}

/* Facility detail */
.facility-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* (score panel styles removed — replaced by conditions-grid) */

/* Stats grid */
.stats-grid table {
    margin: 0;
}

.stats-grid td {
    padding: 0.25rem 0.5rem;
}

/* Photo gallery */
.photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.5rem;
}

.photo-gallery img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    cursor: pointer;
}

.lightbox.open {
    display: flex;
}

.lightbox img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
    cursor: default;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.lightbox-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 3rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    line-height: 1;
    border-radius: 4px;
}

.lightbox-arrow:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }

.lightbox-caption {
    color: #ccc;
    margin-top: 0.75rem;
    font-size: 0.9rem;
    text-align: center;
    max-width: 80vw;
}

.lightbox-counter {
    color: #888;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* Activities */
.activity-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.activity-list .tag {
    background: #e8f4f0;
    color: #2c3e50;
}

/* Facility description HTML cleanup */
.facility-description {
    max-height: 300px;
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Nearby list */
.nearby-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
    gap: 0.5rem;
}

.nearby-item {
    padding: 0.5rem;
    background: #edf2f7;
    border-radius: 6px;
}

.nearby-item a {
    text-decoration: none;
    font-weight: bold;
}

.nearby-item small {
    display: block;
    color: var(--pico-muted-color);
}

/* Map containers */
.results-map { height: 500px; border-radius: 8px; margin-bottom: 1rem; }
.facility-map { height: 350px; border-radius: 8px; }

/* Filter drawer */
.filter-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.35);
    z-index: 999;
}

.filter-overlay.open {
    display: block;
}

.filter-drawer {
    position: fixed;
    top: 0;
    left: -100%;
    width: min(340px, 100vw);
    height: 100vh;
    background: #fff;
    z-index: 1000;
    transition: left 0.3s ease;
    overflow-y: auto;
    padding: 1.25rem;
    box-shadow: 3px 0 12px rgba(0, 0, 0, 0.15);
}

.filter-drawer.open {
    left: 0;
}

.filter-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.filter-close-btn {
    padding: 0.2rem 0.6rem;
    font-size: 1.2rem;
    line-height: 1;
    border: none;
    cursor: pointer;
}

.filter-drawer label strong {
    display: block;
    margin-bottom: 0.15rem;
}

.filter-fieldset {
    border: none;
    padding: 0;
    margin: 0 0 0.75rem 0;
}

.filter-fieldset label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 0.1rem;
}

.filter-apply-btn {
    width: 100%;
    margin-top: 0.5rem;
}

.filter-toggle-btn {
    font-size: 0.9rem;
    padding: 0.3rem 0.7rem;
    margin-right: 0.5rem;
    vertical-align: middle;
    cursor: pointer;
}

/* HTMX loading indicator */
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline;
}

/* Stats page */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stats-card {
    text-align: center;
    margin: 0;
    padding: 1.25rem 0.5rem;
}

.stats-card-value {
    font-size: 2rem;
    font-weight: bold;
    line-height: 1.2;
}

.stats-card-label {
    color: var(--pico-muted-color);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Sparkline (daily activity) */
.sparkline {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 120px;
    padding-bottom: 1.5rem;
    overflow-x: auto;
}

.spark-bar-wrap {
    flex: 1;
    min-width: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    position: relative;
}

.spark-bar {
    width: 100%;
    background: #3b82f6;
    border-radius: 2px 2px 0 0;
    min-height: 2px;
    transition: background 0.15s;
}

.spark-bar-wrap:hover .spark-bar {
    background: #1d4ed8;
}

.spark-label {
    font-size: 0.6rem;
    color: var(--pico-muted-color);
    position: absolute;
    bottom: -1.25rem;
    white-space: nowrap;
}

/* Show every Nth label to prevent overlap */
.spark-bar-wrap:not(:nth-child(7n+1)) .spark-label {
    display: none;
}

/* Horizontal bar charts */
.bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.bar-label {
    flex: 0 0 180px;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bar-label a {
    text-decoration: none;
}

.bar-label code {
    font-size: 0.8rem;
}

.bar-track {
    flex: 1;
    background: #edf2f7;
    border-radius: 4px;
    height: 20px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: #3b82f6;
    border-radius: 4px;
    min-width: 4px;
}

.bar-fill-green { background: #2d7d46; }
.bar-fill-orange { background: #d4782f; }
.bar-fill-slate { background: #64748b; }

.bar-count {
    flex: 0 0 50px;
    text-align: right;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--pico-muted-color);
}

/* Map filter bar (below map) */
.map-filters-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.75rem 0;
    font-size: 0.85rem;
}

.mf-group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.mf-label {
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--pico-muted-color);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.mf-toggle-group {
    display: flex;
    gap: 3px;
}

.mf-toggle {
    padding: 4px 10px;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    color: #555;
    line-height: 1.3;
}

.mf-toggle:hover {
    background: #f0f0f0;
}

.mf-toggle.active {
    background: #2d7d46;
    color: #fff;
    border-color: #2d7d46;
}

.mf-check-row {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.mf-check-row label {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.82rem;
    cursor: pointer;
    white-space: nowrap;
    margin: 0;
}

.mf-check-row input[type="checkbox"] {
    margin: 0;
    width: 14px;
    height: 14px;
}

.mf-rv-input {
    width: 50px;
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.82rem;
    text-align: center;
    margin: 0;
}

.mf-reset-btn {
    padding: 4px 8px;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    color: #555;
    line-height: 1;
}

.mf-reset-btn:hover {
    background: #f0f0f0;
}

/* Responsive */
@media (max-width: 768px) {
    .card-photo { display: none; }
    .card-header-row { flex-direction: column; }
    .results-header { flex-direction: column; }
    .facility-header { flex-direction: column; }
    .photo-gallery { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
    .results-map { height: 350px; }
    .facility-map { height: 280px; }
    .tag-grid { grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr)); }
    .conditions-grid { grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr)); }
    .header-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }
    .header-links a { font-size: 0.85rem; padding: 0.3rem 0.6rem; }
    nav ul li a { font-size: 0.85rem; }
    .stats-cards { grid-template-columns: repeat(2, 1fr); }
    .bar-label { flex: 0 0 140px; }
}

@media (max-width: 480px) {
    .results-map { height: 250px; }
    .facility-map { height: 220px; }
    .container { padding-left: 0.75rem; padding-right: 0.75rem; }
    .header-links { flex-direction: column; }
    .header-links a { width: 100%; text-align: center; }
    .tag-grid { grid-template-columns: 1fr; }
    .nearby-list { grid-template-columns: 1fr; }
    .geo-locate-row { flex-direction: column; align-items: stretch; }
    .search-mode-toggle { flex-direction: column; gap: 0.75rem; }
    .filter-toggle-btn { width: 100%; }
    #state-map { min-height: 250px; }
    .map-filters-bar { gap: 0.5rem; font-size: 0.78rem; }
    .mf-toggle { font-size: 0.75rem; padding: 3px 7px; }
    .mf-check-row label { font-size: 0.75rem; }
    .mf-check-row { gap: 0.4rem; }
    .brand strong { font-size: 0.95rem; }
    .stats-cards { grid-template-columns: repeat(2, 1fr); }
    .stats-card-value { font-size: 1.5rem; }
    .bar-label { flex: 0 0 100px; font-size: 0.8rem; }
    .bar-count { flex: 0 0 40px; font-size: 0.8rem; }
    .sparkline { height: 80px; }
}
