/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-primary: #DC2626;
    --color-primary-hover: #B91C1C;
    --color-text: #1A1A1A;
    --color-text-secondary: #6B7280;
    --color-border: #E5E7EB;
    --color-bg: #FFFFFF;
    --color-bg-secondary: #F7F7F7;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-lg: 16px;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Header ===== */
.header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.header-content {
    max-width: 1440px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--color-primary);
    text-decoration: none;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
}

.nav {
    display: flex;
    gap: 32px;
}

.nav-link {
    color: var(--color-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 15px;
    transition: color 0.2s;
}

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

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-link {
    padding: 8px 16px;
    color: var(--color-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-link:hover {
    color: var(--color-primary);
    background: var(--color-bg-secondary);
}

.btn-primary {
    padding: 8px 16px;
    background: var(--color-primary);
    color: white;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Hide mobile menu toggle by default (desktop) */
.mobile-menu-toggle {
    display: none;
}

/* ===== Mobile Menu ===== */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-menu {
    position: absolute;
    top: 0;
    right: 0;
    width: 80%;
    max-width: 300px;
    height: 100%;
    background: var(--color-bg);
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
}

.mobile-menu-overlay.active .mobile-menu {
    transform: translateX(0);
}

.mobile-menu-header {
    padding: 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-menu-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
}

.mobile-menu-close {
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    color: var(--color-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
}

.mobile-menu-close:hover {
    background: var(--color-bg-secondary);
}

.mobile-menu-nav {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mobile-menu-link {
    padding: 12px 16px;
    color: var(--color-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 16px;
    border-radius: 8px;
    transition: background 0.2s;
}

.mobile-menu-link:hover {
    background: var(--color-bg-secondary);
}

/* ===== User Menu (Logged In) ===== */
.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-user-section {
    margin-top: auto;
    padding: 20px;
    border-top: 1px solid var(--color-border);
}

.mobile-user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
    padding: 12px;
    background: var(--color-bg-secondary);
    border-radius: 8px;
}

.mobile-user-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
}

.mobile-user-email {
    font-size: 14px;
    color: var(--color-text-secondary);
}

/* ===== Hero ===== */
.hero {
    background: linear-gradient(135deg, #FEF2F2 0%, #FFFFFF 100%);
    padding: 64px 24px;
    border-bottom: 1px solid var(--color-border);
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}

.hero-title {
    font-size: 48px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 16px;
    color: var(--color-text);
}

.hero-subtitle {
    font-size: 18px;
    color: var(--color-text-secondary);
    margin-bottom: 32px;
}

.search-box {
    display: flex;
    gap: 12px;
    max-width: 600px;
    margin: 0 auto;
    background: var(--color-bg);
    padding: 8px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.search-input-group {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
}

.search-icon {
    color: var(--color-text-secondary);
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    font-family: inherit;
    background: transparent;
}

.btn-search {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

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

/* ===== Main Content ===== */
.main-content {
    max-width: 1440px;
    margin: 0 auto;
    padding: 32px 24px;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 32px;
    position: relative;
}

.main-content.map-view-active {
    grid-template-columns: 1fr;
}

/* ===== Sidebar ===== */
.sidebar {
    position: sticky;
    top: 96px;
    height: fit-content;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

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

.sidebar-section:last-child {
    border-bottom: none;
}

.sidebar-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-clear-filters {
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
}

.filter-title {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 0;
}

.filter-option input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--color-primary);
}

.filter-label {
    font-size: 15px;
    cursor: pointer;
}

.filter-select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    background: var(--color-bg);
    cursor: pointer;
}

/* ===== Content Area ===== */
.content-area {
    flex: 1;
}

.results-header {
    margin-bottom: 24px;
}

.results-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.results-count {
    font-size: 14px;
    color: var(--color-text-secondary);
}

/* ===== Business Grid ===== */
.business-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 48px;
}

.business-card {
    background: var(--color-bg);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--color-border);
}

.business-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.business-card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: var(--color-bg-secondary);
    position: relative;
}

.business-card-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--color-primary);
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.distance-badge {
    left: 12px;
    right: auto;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
}

.business-card-content {
    padding: 16px;
}

.business-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.business-card-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.business-card-category {
    display: inline-block;
    background: var(--color-bg-secondary);
    color: var(--color-text-secondary);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
}

.business-card-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.rating-star {
    color: #FBBF24;
}

.business-card-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--color-text-secondary);
    font-size: 14px;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.business-card-status {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--color-border);
}

.status-open {
    color: #10B981;
    font-size: 13px;
    font-weight: 600;
}

.status-closed {
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 600;
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 32px;
}

.pagination button {
    padding: 10px 16px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    background: var(--color-bg-secondary);
}

.pagination button.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .hero-title {
        font-size: 32px;
    }

    .hero-subtitle {
        font-size: 16px;
    }

    .search-box {
        flex-direction: column;
    }

    .main-content {
        grid-template-columns: 1fr;
        padding: 24px 16px;
    }

    .sidebar {
        position: static;
    }

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

    .nav {
        display: none;
    }
}

/* ===== Loading State ===== */
.loading {
    text-align: center;
    padding: 48px;
    color: var(--color-text-secondary);
}

.error {
    text-align: center;
    padding: 48px;
    color: var(--color-primary);
}

/* ===== View Toggle (List/Map) ===== */
.view-toggle {
    display: flex;
    gap: 8px;
    background: var(--color-bg-secondary);
    padding: 4px;
    border-radius: var(--radius);
}

.view-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

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

.view-toggle-btn.active {
    background: var(--color-bg);
    color: var(--color-text);
    box-shadow: var(--shadow-sm);
}

/* ===== Map View ===== */
.map-view {
    width: 100%;
    margin-bottom: 48px;
    position: relative;
}

.businesses-map {
    width: 100%;
    height: 600px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

/* ===== Map Sidebar Panel ===== */
.map-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 380px;
    height: 600px;
    background: white;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    overflow-y: auto;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.map-sidebar.active {
    transform: translateX(0);
}

.map-sidebar-header {
    position: sticky;
    top: 0;
    background: white;
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    z-index: 10;
}

.btn-close-sidebar {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--color-bg-secondary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

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

.map-sidebar-photo {
    width: 100%;
    height: 240px;
    object-fit: cover;
    background: var(--color-bg-secondary);
}

.map-sidebar-content {
    padding: 24px;
}

.map-sidebar-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--color-text);
}

.map-sidebar-category {
    display: inline-block;
    background: var(--color-bg-secondary);
    color: var(--color-text-secondary);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 16px;
}

.map-sidebar-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
}

.map-sidebar-info {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.map-sidebar-info-item {
    display: flex;
    gap: 12px;
    font-size: 15px;
    line-height: 1.5;
}

.map-sidebar-info-item svg {
    flex-shrink: 0;
    color: var(--color-primary);
    margin-top: 2px;
}

.map-sidebar-info-item a {
    color: var(--color-text);
    text-decoration: none;
}

.map-sidebar-info-item a:hover {
    color: var(--color-primary);
}

.map-sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

.btn-sidebar-action {
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    text-decoration: none;
    display: block;
}

.btn-sidebar-primary {
    background: var(--color-primary);
    color: white;
    border: none;
}

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

.btn-sidebar-secondary {
    background: white;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

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

/* User Location Button */
.btn-my-location {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    background: white;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: all 0.2s;
    z-index: 999;
}

.btn-my-location:hover {
    background: var(--color-bg-secondary);
    border-color: var(--color-primary);
}

.btn-my-location.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

@media (max-width: 768px) {
    .businesses-map {
        height: 400px;
    }

    .view-toggle-btn span {
        display: none;
    }

    .map-sidebar {
        width: 100%;
        height: 400px;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .map-sidebar-photo {
        height: 180px;
    }

    .map-sidebar-content {
        padding: 16px;
    }
}

/* ===== Leaflet Custom Marker Icons ===== */
.custom-marker-icon {
    background: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-marker-icon div {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.custom-marker-icon:hover div {
    transform: scale(1.2);
}

.user-location-marker {
    background: none;
    border: none;
}

/* ===== Near Me Button ===== */
.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-near-me {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: white;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-near-me:hover {
    background: var(--color-bg);
    border-color: var(--color-primary);
}

.btn-near-me.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.btn-near-me.loading {
    opacity: 0.6;
    pointer-events: none;
}

.btn-near-me svg {
    flex-shrink: 0;
}

.btn-near-me.active svg {
    animation: pulse 2s ease-in-out infinite;
}

.map-category-filter {
    padding: 8px 16px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    background: white;
    color: var(--color-text);
    cursor: pointer;
    min-width: 180px;
    transition: all 0.2s;
}

.map-category-filter:hover {
    border-color: var(--color-primary);
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@media (max-width: 768px) {
    .header-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .btn-near-me span {
        display: inline;
    }
}

/* ===== Footer ===== */
.footer {
    background: var(--color-bg-secondary);
    border-top: 1px solid var(--color-border);
    margin-top: 64px;
    padding: 48px 24px 24px;
}

.footer-content {
    max-width: 1440px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 32px;
    margin-bottom: 32px;
}

.footer-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
}

.footer-heading {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.footer-text {
    font-size: 14px;
    color: var(--color-text-secondary);
    line-height: 1.6;
    margin: 0;
}

.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.footer-link {
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

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

.footer-bottom {
    max-width: 1440px;
    margin: 0 auto;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
}

.footer-copyright {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin: 0;
}

.footer-notice {
    font-size: 12px;
    color: var(--color-text-secondary);
    font-style: italic;
    margin: 0;
}

/* ===== Mobile Filters ===== */
.mobile-filters {
    display: none;
    gap: 12px;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--color-bg-secondary);
    border-radius: 8px;
}

.mobile-category-select,
.mobile-sort-select {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 14px;
    font-family: 'DM Sans', sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    cursor: pointer;
}

.mobile-category-select:focus,
.mobile-sort-select:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* ===== Responsive Styles ===== */
@media (max-width: 768px) {
    /* Header responsive */
    .nav {
        display: none;
    }

    .header-actions .btn-link,
    .header-actions .btn-primary {
        display: none;
    }

    .mobile-menu-toggle {
        display: flex !important;
    }

    /* Hero section responsive */
    .hero {
        padding: 32px 16px;
    }

    .hero-title {
        font-size: 28px;
        line-height: 1.2;
    }

    .hero-subtitle {
        font-size: 14px;
    }

    .search-box {
        flex-direction: column;
        gap: 12px;
    }

    .search-input-group {
        width: 100%;
    }

    .btn-search {
        width: 100%;
    }

    /* Explore page responsive */
    .sidebar {
        display: none;
    }

    .mobile-filters {
        display: flex;
    }

    .main-content {
        display: block;
        padding: 16px;
    }

    .content-area {
        width: 100%;
    }

    /* Results header responsive */
    .results-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .header-controls {
        width: 100%;
        flex-direction: column;
        gap: 12px;
    }

    .view-toggle {
        width: 100%;
    }

    .view-toggle-btn {
        flex: 1;
    }

    .btn-near-me {
        width: 100%;
        justify-content: center;
    }

    /* Business grid responsive */
    .business-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* Pagination responsive */
    .pagination {
        gap: 4px;
    }

    .pagination button {
        padding: 8px 12px;
        font-size: 14px;
    }

    /* Footer responsive */
    .footer-content {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}
