/* Marketplace ============================================================ */

.page-header {
    padding: 64px 0 32px;
    text-align: center;
}
.page-header h1 { margin: 0 0 16px; }
.page-header p { max-width: 720px; margin: 0 auto 8px; opacity: 0.85; }
.page-header-meta {
    font-size: 14px;
    opacity: 0.7;
    margin-top: 16px;
}

main.wrap {
    padding-bottom: 96px;
}

.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 0 0 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.filter-bar > * {
    height: 42px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.25);
    color: inherit;
    font: inherit;
    padding: 0 14px;
}
.filter-bar input[type="search"] {
    flex: 1 1 280px;
    min-width: 240px;
}
.filter-bar select { min-width: 160px; cursor: pointer; }
.filter-bar .btn-near-me { white-space: nowrap; }

.market-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin: 0 0 16px;
}
.view-toggle {
    display: inline-flex;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
}
.view-toggle button {
    background: rgba(0, 0, 0, 0.25);
    border: 0;
    color: inherit;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: 500;
    font-family: inherit;
}
.view-toggle button.active {
    background: rgba(124, 58, 237, 0.35);
}

/* Sort chips: pill row that re-queries the server on click */
.sort-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.sort-chips-label {
    color: var(--text-muted);
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-right: 2px;
}
.sort-chip {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text-muted);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sort-chip:hover { color: var(--white); border-color: rgba(255,255,255,0.25); }
.sort-chip.active {
    background: rgba(124, 58, 237, 0.4);
    color: var(--white);
    border-color: rgba(124, 58, 237, 0.6);
}

/* Grid view: tabular layout with sortable headers */
.grid-headers {
    display: grid;
    grid-template-columns: 2.4fr 1.6fr 0.8fr 0.8fr 1fr;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px 10px 0 0;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 700;
}
.grid-headers .grid-col[data-sort] {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}
.grid-headers .grid-col[data-sort]:hover { color: var(--white); }
.grid-headers .grid-col.active { color: var(--white); }
.grid-headers .grid-col[data-sort]::after {
    content: attr(data-arrow);
    margin-left: 4px;
    opacity: 0.7;
}

body.view-grid .directory-feed-list,
.directory-feed-list.feed-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid rgba(255,255,255,0.08);
    border-top: 0;
    border-radius: 0 0 10px 10px;
    overflow: hidden;
}
.grid-row {
    display: grid;
    grid-template-columns: 2.4fr 1.6fr 0.8fr 0.8fr 1fr;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    color: inherit;
    text-decoration: none;
    font-size: 13px;
    align-items: center;
    transition: background 0.12s;
}
.grid-row:last-child { border-bottom: 0; }
.grid-row:hover { background: rgba(124, 58, 237, 0.08); text-decoration: none; }
.grid-row .grid-name { color: var(--white); font-weight: 600; }
.grid-row .grid-dim { color: var(--text-muted); opacity: 0.6; }
.grid-row .grid-cei {
    display: inline-block;
    background: #fcdc04;
    color: #0e1f40;
    border-radius: 5px;
    padding: 1px 7px;
    font-weight: 800;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}
.ownership-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}
.ownership-dot.dot-rainbow {
    background: linear-gradient(135deg, #ff5d8f, #ffa64d, #f7e733, #4ad991, #4dabf7, #c084fc);
}
.ownership-dot.dot-ally { background: #67e8f9; }
.grid-row-apple { background: rgba(255,255,255,0.02); }
.grid-row-apple .grid-name { color: var(--text-muted); font-style: italic; }

@media (max-width: 720px) {
    .grid-headers, .grid-row { grid-template-columns: 2fr 1fr 0.6fr; }
    .grid-headers .col-own, .grid-headers .col-date,
    .grid-row .col-own, .grid-row .col-date { display: none; }
}

#directory-map {
    width: 100%;
    height: 360px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin: 0 0 24px;
    background: #111;
}

.result-count {
    font-size: 13px;
    opacity: 0.7;
    margin: 0 0 12px;
}

/* Card / list views */
.directory-feed-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
body.view-cards .directory-feed-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.listing-card {
    display: block;
    padding: 16px 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    transition: border-color 0.2s, transform 0.2s;
    color: inherit;
    text-decoration: none;
}
.listing-card:hover {
    border-color: rgba(124, 58, 237, 0.5);
    transform: translateY(-2px);
    text-decoration: none;
}

.listing-name-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 6px;
}
.listing-name-row h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}
.listing-distance {
    font-size: 12px;
    opacity: 0.6;
    white-space: nowrap;
}

.listing-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.6;
}
.badge-rainbow {
    background: linear-gradient(90deg, #ff5757 0%, #ff9c33 25%, #ffd333 50%, #5cd65c 75%, #5c9cff 100%);
    color: #000;
}
.badge-ally {
    background: rgba(124, 58, 237, 0.25);
    color: #c7a8ff;
    border: 1px solid rgba(124, 58, 237, 0.5);
}
.badge-verified {
    background: rgba(72, 187, 120, 0.18);
    color: #6fe0a4;
    border: 1px solid rgba(72, 187, 120, 0.45);
}
.badge-unverified {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.45);
}
.badge-apple {
    background: rgba(150, 150, 150, 0.18);
    color: #d1d5db;
    border: 1px solid rgba(150, 150, 150, 0.4);
}
.listing-card-apple {
    border-style: dashed;
    opacity: 0.92;
}
.listing-card-apple:hover { opacity: 1; }

/* Sponsored ad card — visually distinct from normal listings without being
   clickbait. Uses the brand gradient on the left border. */
.listing-card-ad {
    border: 1px solid var(--dark-border);
    border-left: 3px solid;
    border-image: linear-gradient(180deg, #c478ce, #f59e0b) 1;
    background: linear-gradient(180deg, rgba(196, 120, 206, 0.05), transparent);
}
.listing-card-ad:hover { background: linear-gradient(180deg, rgba(196, 120, 206, 0.10), transparent); }
.listing-ad-image {
    width: 100%;
    max-height: 120px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 8px;
}
.badge-ad {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.4);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.listing-category {
    font-size: 11px;
    opacity: 0.6;
    margin-left: auto;
}
.listing-detail {
    font-size: 14px;
    opacity: 0.8;
    line-height: 1.45;
    margin-bottom: 6px;
}
.listing-website {
    font-size: 13px;
    color: #c7a8ff;
    text-decoration: none;
}
.listing-website:hover { text-decoration: underline; }

.loading, .error, .empty {
    padding: 32px;
    text-align: center;
    opacity: 0.7;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
}
.error { color: #ff8a8a; }

.load-more-wrap {
    text-align: center;
    margin: 32px 0;
}

/* Add a business */
.add-business-cta {
    margin-top: 64px;
    padding: 32px;
    background: rgba(124, 58, 237, 0.08);
    border: 1px solid rgba(124, 58, 237, 0.25);
    border-radius: 16px;
}
.add-business-cta h2 { margin: 0 0 8px; font-size: 22px; }
.add-business-cta p { margin: 0 0 16px; opacity: 0.85; }
.add-search {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.add-search input {
    flex: 1 1 320px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.25);
    color: inherit;
    padding: 0 14px;
}

#apple-suggestions {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.apple-place {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.apple-place .muted { opacity: 0.6; font-size: 13px; }

@media (max-width: 720px) {
    .filter-bar > * { flex: 1 1 100%; }
    #directory-map { height: 240px; }
}

/* Detail view ============================================================ */

.back-link {
    display: inline-block;
    margin: 24px 0 12px;
    font-size: 14px;
    color: #c7a8ff;
    text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

.detail-hero {
    display: flex;
    gap: 24px;
    padding: 28px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    margin-bottom: 24px;
}
.detail-hero-logo {
    width: 140px;
    height: 140px;
    flex-shrink: 0;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 12px;
    padding: 12px;
}
.detail-hero-placeholder {
    width: 140px;
    height: 140px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(124, 58, 237, 0.15);
    border-radius: 12px;
    font-size: 48px;
}
.detail-hero-content { flex: 1; min-width: 0; }
.detail-hero-content h1 {
    margin: 0 0 8px;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
}
.detail-subtitle {
    margin: 0 0 12px;
    font-size: 16px;
    opacity: 0.85;
    line-height: 1.4;
}

.detail-meta-list {
    list-style: none;
    padding: 0;
    margin: 16px 0 0;
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 8px 16px;
    font-size: 14px;
}
.detail-meta-list li {
    display: contents;
}
.detail-meta-label {
    font-weight: 600;
    opacity: 0.6;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.04em;
    align-self: center;
}
.detail-meta-value { line-height: 1.5; }
.detail-meta-value a { color: #c7a8ff; text-decoration: none; }
.detail-meta-value a:hover { text-decoration: underline; }

.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
}
/* Tighter button sizing in the org-detail action row — the default .btn
   (14px 32px / 1rem) is too chunky when 3-4 of them sit side-by-side. */
.detail-actions .btn,
#org-detail .btn {
    padding: 8px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0;
}

/* HRC CEI chip on listing cards + detail page */
.badge-cei {
    background: #fcdc04;
    color: #0e1f40;
    border: 1px solid #0e1f40;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.badge-cei .badge-cei-eq {
    background: #0e1f40;
    color: #fcdc04;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.62rem;
    font-weight: 900;
    line-height: 1;
}
.badge-cei.badge-cei-eoc { box-shadow: 0 0 0 2px rgba(252, 220, 4, 0.25); }

/* HRC CEI score history chart */
.cei-heading {
    font-size: 1.4rem;
    margin-top: 32px;
    margin-bottom: 4px;
}
.cei-sublabel {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0 0 12px;
}
.cei-chart-wrap {
    background: var(--dark-card);
    border: 1px solid var(--dark-border);
    border-radius: 10px;
    padding: 8px 4px 4px;
    overflow: hidden;
}
.cei-chart-wrap svg {
    display: block;
    width: 100%;
    height: auto;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
}
.cei-footnote {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin: 8px 4px 0;
    line-height: 1.5;
}

/* Reviews section (live Yelp + Google) */
.reviews-heading {
    font-size: 1.4rem;
    margin-top: 32px;
    margin-bottom: 12px;
}
.reviews-aggregates {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.review-agg {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--dark-border);
    border-radius: 999px;
    padding: 4px 12px;
}
.reviews-list {
    display: grid;
    gap: 14px;
    grid-template-columns: 1fr;
}
@media (min-width: 720px) {
    .reviews-list { grid-template-columns: 1fr 1fr; }
}
.review-card {
    background: var(--dark-card);
    border: 1px solid var(--dark-border);
    border-radius: 10px;
    padding: 14px 16px;
}
.review-head {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}
.review-author-photo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.review-author-name { font-weight: 600; font-size: 0.92rem; }
.review-author-name a { color: inherit; text-decoration: none; }
.review-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 1px; }
.review-source { font-weight: 600; }
.review-source-yelp { color: #ff1a1a; }
.review-source-google { color: #4285F4; }
.review-stars { letter-spacing: 1px; color: #fbbf24; }
.review-text { font-size: 0.88rem; line-height: 1.55; color: var(--text); max-height: 8em; overflow: hidden; }

.detail-socials {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
    font-size: 13px;
}
.detail-socials a {
    color: #c7a8ff;
    text-decoration: none;
    padding: 4px 12px;
    border: 1px solid rgba(124, 58, 237, 0.35);
    border-radius: 999px;
}
.detail-socials a:hover {
    background: rgba(124, 58, 237, 0.18);
    text-decoration: none;
}

.detail-description {
    padding: 20px 24px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    margin-bottom: 24px;
    line-height: 1.6;
    white-space: pre-line;
}

#detail-map {
    width: 100%;
    height: 360px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 24px;
    background: #111;
}

.badge-category {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.12);
}
.badge-orgtype {
    background: rgba(124, 58, 237, 0.12);
    color: #c7a8ff;
    border: 1px solid rgba(124, 58, 237, 0.3);
    text-transform: capitalize;
}

#chamber-members:empty { display: none; }
.members-heading {
    margin: 8px 0 16px;
    font-size: 22px;
    display: flex;
    align-items: baseline;
    gap: 12px;
}
.members-count {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.65;
}
.members-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 48px;
}

@media (max-width: 720px) {
    .detail-hero { flex-direction: column; padding: 20px; }
    .detail-hero-logo, .detail-hero-placeholder { width: 100px; height: 100px; }
    .detail-hero-content h1 { font-size: 22px; }
    #detail-map { height: 240px; }
}
