/* Pioneer Valley Kids Camps - Styles */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #16a34a;
    --warning-color: #d97706;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

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

[hidden] {
    display: none !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

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

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color), #7c3aed);
    color: white;
    padding: 2rem 0;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

header .subtitle {
    opacity: 0.9;
    font-size: 1.1rem;
}

/* Filters Section */
.filters-section {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin: 1.5rem 0;
}

.search-box {
    margin-bottom: 1rem;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    transition: border-color 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.filter-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.filter-group select {
    width: 100%;
    padding: 0.5rem;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: white;
    cursor: pointer;
}

.age-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.age-inputs select {
    flex: 1;
}

.age-inputs span {
    color: var(--text-secondary);
}

.filters-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.95rem;
}

.checkbox-label input {
    width: 1.1rem;
    height: 1.1rem;
    cursor: pointer;
}

.filter-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

#results-count {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Buttons */
.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--secondary-color);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--background);
    border-color: var(--secondary-color);
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: underline;
    font-size: inherit;
}

/* Results Grid */
.results-section {
    margin: 1.5rem 0;
}

.camps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* Table View Styles */
.camps-table-container {
    display: none;
    overflow-x: auto;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.camps-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
    /* Prevent squishing on mobile */
}

.camps-table th {
    background: var(--background);
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.camps-table th:hover {
    background: #e2e8f0;
    color: var(--text-primary);
}

.camps-table th.sortable::after {
    content: ' ⇅';
    opacity: 0.3;
    font-size: 0.8em;
    margin-left: 4px;
}

.camps-table th.sorted-asc::after {
    content: ' ↑';
    opacity: 1;
    color: var(--primary-color);
}

.camps-table th.sorted-desc::after {
    content: ' ↓';
    opacity: 1;
    color: var(--primary-color);
}

.camps-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.camps-table tr:last-child td {
    border-bottom: none;
}

.camps-table tr:hover {
    background-color: var(--background);
}

/* Which view is visible is driven by body[data-view] (set in render()).
   Grid is the default; each other view shows its section and hides the rest. */
body[data-view="list"] .camps-grid {
    display: none;
}

body[data-view="list"] .camps-table-container {
    display: block;
}

.view-toggle {
    display: flex;
    gap: 0.25rem;
    background: var(--background);
    padding: 0.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.btn-toggle {
    background: transparent;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-toggle:hover {
    color: var(--primary-color);
    background: rgba(0, 0, 0, 0.05);
}

.btn-toggle.active {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Camp Card */
.camp-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.camp-card:hover {
    box-shadow: var(--shadow-lg);
}

.camp-card-header {
    padding: 1rem 1rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.camp-card-header h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.camp-organization {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.camp-row-org {
    font-size: 0.85em;
    color: var(--text-secondary);
}

.camp-card-body {
    padding: 1rem;
}

.camp-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.camp-meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-secondary);
}

.camp-meta-item strong {
    color: var(--text-primary);
}

.camp-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.camp-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.camp-tag {
    background: var(--background);
    color: var(--text-secondary);
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.8rem;
}

.camp-tag.category {
    background: #dbeafe;
    color: #1e40af;
}

.camp-badges {
    display: flex;
    gap: 0.5rem;
}

.badge {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-aid {
    background: #e0e7ff;
    color: #4338ca;
}

.badge-early {
    background: #fef3c7;
    color: #92400e;
}

/* Camp Card Title as Button */
.camp-title-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
    text-align: left;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
}

.camp-title-btn:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Modal */
body.modal-open {
    overflow: hidden;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-close:hover {
    background: var(--background);
    color: var(--text-primary);
}

#modal-body {
    padding: 1.5rem;
}

.modal-header {
    margin-bottom: 1rem;
    padding-right: 2rem;
}

.modal-header h2 {
    font-size: 1.4rem;
    margin-bottom: 0.25rem;
}

.modal-header .organization {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.modal-section {
    margin-bottom: 1.25rem;
}

.modal-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.modal-section p,
.modal-section ul {
    font-size: 0.95rem;
    line-height: 1.6;
}

.modal-section ul {
    margin: 0;
    padding-left: 1.25rem;
}

.modal-section li {
    margin-bottom: 0.25rem;
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.modal-verified {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.modal-link {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: var(--radius);
    font-weight: 500;
}

.modal-link:hover {
    background: var(--primary-hover);
}

.modal-incomplete {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #fef3c7;
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: #92400e;
}

/* No Results / Loading */
.no-results,
.loading {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

/* Suggest Section */
.suggest-section {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    margin: 2rem 0;
}

.suggest-section h2 {
    margin-bottom: 0.5rem;
}

.suggest-section>p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.suggest-form {
    max-width: 500px;
    margin: 1.5rem auto 0;
    text-align: left;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.6rem;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Footer */
footer {
    background: var(--text-primary);
    color: #94a3b8;
    padding: 2rem 0;
    margin-top: 2rem;
    text-align: center;
    font-size: 0.9rem;
}

footer p {
    margin-bottom: 0.5rem;
}

footer a {
    color: #cbd5e1;
}

/* ----- Summer Planner: star buttons ----- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.star-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    line-height: 1;
    color: #cbd5e1;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: color 0.15s, transform 0.15s;
}

.star-btn:hover {
    color: var(--warning-color);
    transform: scale(1.15);
}

.star-btn.starred {
    color: var(--warning-color);
}

.camp-card-header {
    position: relative;
}

.camp-card-header .star-btn {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
}

.camp-card-header h3 {
    padding-right: 2rem;
}

.camps-table .star-col {
    width: 2.5rem;
    padding-left: 0.75rem;
    padding-right: 0;
    cursor: default;
}

.camps-table th.star-col:hover {
    background: var(--background);
}

.modal-header {
    position: relative;
}

.modal-header .star-btn {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 1.5rem;
}

/* ----- Summer Planner view ----- */
.planner-section {
    display: none;
    margin: 1.5rem 0;
}

body[data-view="planner"] .planner-section {
    display: block;
}

body[data-view="planner"] .results-section {
    display: none;
}

.planner-count {
    background: var(--warning-color);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 999px;
    padding: 0 0.35rem;
    margin-left: 0.25rem;
    min-width: 1.1rem;
    text-align: center;
}

.planner-empty {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2.5rem 1.5rem;
    text-align: center;
}

.planner-empty p {
    max-width: 480px;
    margin: 0.75rem auto 1.25rem;
    color: var(--text-secondary);
}

.planner-summary {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.summary-strip {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.summary-week {
    flex: 1 0 90px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.5rem;
    text-align: center;
    background: var(--background);
}

.summary-week.covered {
    border-color: var(--success-color);
    background: #f0fdf4;
}

.summary-date {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
}

.summary-camp {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 110px;
    margin: 0 auto;
}

.summary-none {
    color: var(--text-secondary);
    opacity: 0.5;
}

.summary-totals {
    margin-top: 0.5rem;
    font-size: 0.95rem;
}

.planner-grid-wrap {
    overflow-x: auto;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.planner-grid {
    border-collapse: collapse;
    width: 100%;
}

.planner-grid th,
.planner-grid td {
    border-bottom: 1px solid var(--border-color);
    padding: 0.4rem;
    text-align: center;
}

.planner-grid thead th {
    background: var(--background);
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    padding: 0.6rem 0.4rem;
}

.planner-grid .planner-camp-col {
    position: sticky;
    left: 0;
    background: var(--surface);
    text-align: left;
    min-width: 180px;
    max-width: 220px;
    padding: 0.6rem 0.75rem;
    z-index: 1;
    box-shadow: 1px 0 0 var(--border-color);
}

.planner-grid thead .planner-camp-col {
    background: var(--background);
}

.planner-grid .camp-title-btn {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
}

.planner-grid .camp-title-btn:hover {
    color: var(--primary-color);
}

.planner-camp-meta {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.unstar-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.unstar-btn:hover {
    color: #dc2626;
}

.cell-btn {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 6px;
    border: 1px dashed var(--border-color);
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.cell-avail .cell-btn {
    color: #cbd5e1;
}

.cell-avail .cell-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #eff6ff;
}

.cell-assigned .cell-btn {
    background: var(--primary-color);
    border: 1px solid var(--primary-color);
    color: white;
}

.cell-na {
    background: repeating-linear-gradient(45deg, transparent, transparent 4px, #f1f5f9 4px, #f1f5f9 8px);
}

.planner-no-dates {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.5rem;
    margin-top: 1.5rem;
}

.planner-no-dates h3 {
    margin-bottom: 0.25rem;
}

.planner-no-dates > p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.planner-no-dates ul {
    list-style: none;
}

.planner-no-dates li {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.4rem 0;
    flex-wrap: wrap;
}

.planner-no-dates .camp-title-btn {
    background: none;
    border: none;
    padding: 0;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    cursor: pointer;
}

.planner-no-dates .camp-title-btn:hover {
    color: var(--primary-color);
}

.planner-note {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.5rem;
    color: var(--text-secondary);
}

.planner-actions {
    margin-top: 1.5rem;
}

.planner-actions {
    display: flex;
    gap: 0.75rem;
}

/* ----- Map view ----- */
.map-section {
    display: none;
}

body[data-view="map"] .map-section {
    display: block;
}

body[data-view="map"] .results-section {
    display: none;
}

#map {
    height: 600px;
    width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background: var(--background);
    z-index: 0;
}

.map-loading {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.map-legend {
    display: flex;
    gap: 1.25rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.map-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
}

.legend-precise {
    background: #3388ff;
    border: 2px solid #2563eb;
}

.legend-approx {
    background: #fbbf24;
    border: 2px solid #d97706;
    opacity: 0.6;
}

.map-unmapped {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.map-popup strong {
    font-size: 1rem;
}

.map-details-btn {
    margin-top: 0.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.3rem 0.7rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.map-details-btn:hover {
    background: var(--primary-hover);
}

/* ----- Responsive (all breakpoints in one place) ----- */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }

    .filters-grid {
        grid-template-columns: 1fr 1fr;
    }

    .filter-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .camps-grid {
        grid-template-columns: 1fr;
    }

    .camps-table th,
    .camps-table td {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    #map {
        height: 70vh;
    }
}

@media (max-width: 480px) {
    .filters-grid {
        grid-template-columns: 1fr;
    }

    .filters-checkboxes {
        flex-direction: column;
    }
}
