/* Built By Kristian Cook - https://builtbykristian.netlify.app - MIT License */
:root {
    --bg: #1a1816;
    --surface: #faf8f5;
    --text: #2c2825;
    --muted: #6b6560;
    --primary: #8b6f47;
    --primary-dark: #6b563a;
    --accent: #d4a574;
    --border: #e8e3dc;
    --radius: 12px;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans";
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

#app-container {
    display: flex;
    height: 100vh;
}

#sidebar {
    width: 480px;
    max-width: 100vw;
    height: 100vh;
    background: var(--surface);
    overflow-y: auto;
    flex-shrink: 0;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.1);
}

#map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 2px solid var(--border);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.sidebar-header h1 {
    margin: 0 0 6px 0;
    font-size: 1.4rem;
    color: white;
    text-align: center;
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
    font-size: 14px;
    text-align: center;
}

.controls {
    display: grid;
    gap: 10px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.control-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: white;
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 8px;
    flex: 1;
    min-width: 0;
}

.inline input,
.inline select {
    background: transparent;
    border: none;
    color: var(--text);
    outline: none;
    flex: 1;
    min-width: 0;
}

.inline label {
    color: var(--muted);
    font-weight: 500;
    font-size: 14px;
}

.primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    transition: background 0.2s;
}

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

.button {
    background: white;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.2s, background 0.2s;
}

.button:hover {
    border-color: var(--primary);
    background: var(--accent);
    color: white;
}

.sidebar-section {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar-section h3 {
    margin: 6px 0 10px;
}

.note {
    color: var(--muted);
    font-size: 13px;
}

.card-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 12px;
}

.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(139, 111, 71, 0.15);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-weight: 600;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    background: var(--accent);
    color: white;
    font-size: 12px;
    font-weight: 500;
}

.card-body {
    padding: 10px 12px;
    display: grid;
    gap: 6px;
    font-size: 14px;
    text-align: center;
}

.actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.gallery {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    justify-content: center;
}

.gallery img {
    width: 150px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.pagination {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* ----------------- MODAL ----------------- */
.modal.hidden {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    z-index: 1000;
    font-family: inherit;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    backdrop-filter: blur(3px);
}

/* MAIN CONTAINER */
.modal-content {
    position: relative;
    width: min(980px, 96vw);
    max-height: 92vh;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-y: auto;
    z-index: 101;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
    padding: 24px;
    text-align: center;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--text);
    color: var(--surface);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
}

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

/* Top gallery, centered */
.top-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.top-gallery img {
    width: 100%;
    height: 280px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid var(--border);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

/* If only 1 image, center it and make it bigger */
.top-gallery.single-image {
    grid-template-columns: 1fr;
    max-width: 500px;
    margin: 0 auto 24px;
}

.top-gallery.single-image img {
    height: 350px;
}

/* Title & category centered */
.modal-header {
    text-align: center;
    margin-bottom: 24px;
}

.modal-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 8px 0;
}

.modal-subtitle {
    font-size: 1rem;
    color: var(--muted);
    margin: 0 0 8px 0;
}

.rating {
    color: var(--accent);
    font-size: 18px;
    font-weight: 600;
}

/* Two-column grid for business details */
.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.info-card {
    background: white;
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: 10px;
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-self: start;
    align-items: center;
    /* ✅ This makes cards only as tall as their content */
}

.info-card h4 {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-card p {
    margin: 4px 0;
    font-size: 1rem;
    color: var(--text);
    line-height: 1.6;
}

.info-card p:first-of-type {
    margin-top: 0;
}

.info-card p:last-of-type {
    margin-bottom: 0;
}

.info-card a {
    color: var(--primary);
    text-decoration: none;
}

.info-card a:hover {
    text-decoration: underline;
}

/* Full width info cards */
.info-card.full-width {
    grid-column: 1 / -1;
}

/* Reviews section */
.reviews-section {
    grid-column: 1 / -1;
}

.reviews-section h3 {
    font-size: 1.3rem;
    color: var(--primary);
    margin: 0 0 16px 0;
    font-weight: 700;
}

.reviews-wrap {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 40vh;
    overflow-y: auto;
    padding-right: 6px;
}

.review {
    background: white;
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: 10px;
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
}

.review .author {
    font-weight: 600;
    color: var(--text);
}

.review .date {
    color: var(--muted);
    font-size: 0.85rem;
}

.review .rating {
    color: var(--accent);
    font-size: 16px;
    margin-bottom: 6px;
}

.review .text {
    color: var(--text);
    line-height: 1.6;
    font-size: 0.95rem;
}

/* Mapbox popup styling */
.mapboxgl-popup-content {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}

.mapboxgl-popup-close-button {
    color: var(--text);
    font-size: 20px;
}

.mapboxgl-ctrl-attrib {
    background: rgba(255, 255, 255, 0.8) !important;
}

/* ==================== TABS ==================== */
#tabs {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-bottom: 2px solid var(--border);
    background: var(--surface);
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    background: white;
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.tab-btn:hover {
    border-color: var(--accent);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 111, 71, 0.15);
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(139, 111, 71, 0.25);
}

.tab-btn.active:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(139, 111, 71, 0.35);
}

/* ==================== TAB CONTENT ==================== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ==================== ADD BUSINESS MODAL SPECIFIC ==================== */
#addBizModal h3 {
    font-size: 1.5rem;
    color: var(--primary);
    margin: 0 0 24px 0;
    text-align: center;
    font-weight: 700;
}

/* Compact grid layout for add business form */
#addBizModal .modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 0;
    text-align: center;
}

/* Full width fields */
#addBizModal .modal-grid .full-width {
    grid-column: 1 / -1;
    justify-items: center;
}

#addBizModal label {
    display: flex;
    flex-direction: column;
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
    gap: 6px;
    text-align: center;
}

#addBizModal input,
#addBizModal select,
#addBizModal textarea {
    width: 100%;
    padding: 10px 35px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: white;
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;

    /* ✅ Center text vertically */
    display: flex;
    align-items: center;
    line-height: 1.5;

    /* ✅ Fix for select dropdown */
    height: 42px;
    /* Consistent height for inputs and selects */
}

#addBizModal textarea {
    resize: vertical;
    min-height: 100px;
    height: auto;
    /* ✅ Override fixed height for textarea */
    line-height: 1.5;
    display: block;
    /* ✅ Reset display for textarea */
}

#addBizModal input:focus,
#addBizModal select:focus,
#addBizModal textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 111, 71, 0.1);
}

#addBizModal input::placeholder,
#addBizModal textarea::placeholder {
    color: var(--muted);
    font-size: 14px;
    text-align: center;
    min-height: 140px !important;
    /* ✅ Increased from 100px */
}

/* ✅ Make select arrows vertically centered */
#addBizModal select {
    appearance: none;
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    text-align: center;
}

/* Submit button styling */
#submitBizBtn {
    grid-column: 1 / -1;
    margin-top: 8px;
    font-size: 16px;
    padding: 14px 20px;
    transition: all 0.3s ease;
}

#submitBizBtn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(139, 111, 71, 0.3);
}

#submitBizBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#submitBizBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(139, 111, 71, 0.3);
}

/* ==================== OPEN ADD BUSINESS BUTTON ==================== */
#openAddBizModal {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(139, 111, 71, 0.2);
    margin-bottom: 12px;
}

#openAddBizModal:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 111, 71, 0.35);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

#openAddBizModal:active {
    transform: translateY(0);
}

.help-link {
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

.help-link:hover {
    color: var(--primary-dark);
}

/* ==================== MOBILE RESPONSIVE ==================== */
@media (max-width: 768px) {

    /* ---------- TABS ---------- */
    #tabs {
        padding: 10px;
    }

    .tab-btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    /* ---------- FORMS ---------- */
    #addBizModal .modal-grid,
    .modal-grid {
        grid-template-columns: 1fr;
    }

    /* ---------- MODAL (FULL MOBILE CONTROL) ---------- */
    .modal {
        align-items: flex-start !important;
        /* push it UP */
        justify-content: flex-start !important;
        padding-top: 20px;
        /* distance from top */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        isolation: isolate;
        /* prevent backdrop bleed-through */
    }

    .modal-backdrop {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    .modal-content {
        width: 100vw;
        max-width: 250vw;
        margin: 0 auto;
        border-radius: 35px;
        overflow: visible;
        background: var(--surface) !important;
        transform: translateY(-40px);
        /* MOVE MODAL UPWARD */
        max-height: none;
        min-height: auto;
        backdrop-filter: none !important;
        padding: 30px 0px;
        /* bigger padding = more space inside */
    }

    .modal-body {
        padding: 20px;
        padding-bottom: 40px;
    }

    .modal-header {
        position: sticky;
        top: 0;
        z-index: 10;
        padding: 15px 20px;
        border-top-left-radius: 12px;
        border-top-right-radius: 12px;
    }

    /* ---------- APP LAYOUT ---------- */
    #app-container {
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }

    #map-container {
        flex: none;
        width: 100%;
        height: 100vh;
        position: relative;
    }

    /* ---------- SIDEBAR (SLIDE UP) ---------- */
    #sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 85vh;
        max-height: 85vh;
        transform: translateY(100%);
        transition: transform 0.35s ease;
        z-index: 50;
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.25);
    }

    #sidebar.open {
        transform: translateY(0);
    }

    .sidebar-header {
        position: relative;
        padding-top: 28px;
    }

    .sidebar-header::before {
        content: "";
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 5px;
        border-radius: 5px;
        background: rgba(255, 255, 255, 0.6);
    }

    /* ---------- CARDS, CONTROLS ---------- */
    .card-body,
    .card-header {
        padding: 12px;
    }

    .gallery img {
        height: 70px;
    }

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

    .control-row {
        flex-direction: column;
    }

    .inline {
        width: 100%;
    }

    /* ---------- MOBILE TOGGLE BUTTON ---------- */
    .mobile-toggle {
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 60;
        background: var(--primary);
        color: white;
        border: none;
        padding: 14px 18px;
        border-radius: 50px;
        font-size: 16px;
        font-weight: 600;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        cursor: pointer;
        transition: background 0.2s, transform 0.2s;
        display: block;
    }

    .mobile-toggle:hover {
        background: var(--primary-dark);
        transform: scale(1.05);
    }
}

/* Hide toggle on desktop */
@media (min-width: 769px) {
    .mobile-toggle {
        display: none;
    }
}