/* Farm Map Page Styles */

/* ── Layout ───────────────────────────────────────────────────────── */

.farm-map-container {
    display: flex;
    height: calc(100vh - 73px);
    overflow: hidden;
    position: relative;
}

/* ── Sidebar ──────────────────────────────────────────────────────── */

.farm-map-sidebar {
    width: 380px;
    min-width: 380px;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, min-width 0.3s ease;
    z-index: 10;
    overflow: hidden;
}

.farm-map-container.sidebar-collapsed .farm-map-sidebar {
    width: 0;
    min-width: 0;
}

/* Toggle button - positioned in container so it's always visible */
.sidebar-toggle-btn {
    position: absolute;
    top: 12px;
    left: 380px;
    z-index: 20;
    width: 32px;
    height: 32px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-left: none;
    border-radius: 0 8px 8px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.08);
    transition: left 0.3s ease, background 0.2s;
}

.sidebar-toggle-btn:hover {
    background: #f0fdf4;
}

.farm-map-container.sidebar-collapsed .sidebar-toggle-btn {
    left: 0;
    border-left: 1px solid #e5e7eb;
    border-radius: 0 8px 8px 0;
}

/* ── Sidebar Header ───────────────────────────────────────────────── */

.sidebar-header {
    padding: 14px 16px 10px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Search row */
.search-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-input-wrapper {
    flex: 1;
    position: relative;
}

.sidebar-search {
    width: 100%;
    padding: 9px 32px 9px 40px !important;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f9fafb url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") no-repeat 12px center !important;
    background-size: 16px 16px !important;
}

.sidebar-search:focus {
    border-color: #16a34a;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") no-repeat 12px center !important;
    background-size: 16px 16px !important;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
    z-index: 1;
    width: 16px !important;
    height: 16px !important;
}

.clear-search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
}

.clear-search-btn:hover {
    color: #4b5563;
    background: #f3f4f6;
}

.clear-search-btn.hidden {
    display: none;
}

/* Near Me button */
.near-me-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #f9fafb;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.near-me-btn:hover {
    border-color: #4285F4;
    color: #4285F4;
    background: #eff6ff;
}

.near-me-btn.active {
    border-color: #4285F4;
    background: #dbeafe;
    color: #2563eb;
}

.near-me-btn.locating {
    animation: pulse-locate 1s ease-in-out infinite;
}

@keyframes pulse-locate {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Type Filter Pills ────────────────────────────────────────────── */

.type-filter-row {
    display: flex;
    gap: 6px;
}

.type-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.type-pill:hover {
    border-color: #16a34a;
    color: #15803d;
}

.type-pill.active {
    background: #f0fdf4;
    border-color: #16a34a;
    color: #15803d;
    font-weight: 600;
}

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

.pill-dot.farmsource {
    background: #16a34a;
}

.pill-dot.partner {
    background: #2563eb;
}

/* ── Filter Dropdowns ─────────────────────────────────────────────── */

.filter-controls-row {
    display: flex;
    gap: 8px;
}

.filter-select {
    flex: 1;
    padding: 6px 28px 6px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 12px;
    color: #374151;
    background: #fff;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: border-color 0.2s;
}

.filter-select:focus {
    border-color: #16a34a;
    box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.08);
}

/* ── Filter Summary Row ───────────────────────────────────────────── */

.filter-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.farm-count-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.clear-all-btn {
    font-size: 11px;
    color: #dc2626;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    transition: background 0.2s;
}

.clear-all-btn:hover {
    background: #fef2f2;
}

.clear-all-btn.hidden {
    display: none;
}

/* ── Farm List ────────────────────────────────────────────────────── */

.farm-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.farm-list-card {
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
    animation: fadeSlideIn 0.3s ease backwards;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.farm-list-card:hover {
    border-color: #16a34a;
    box-shadow: 0 2px 10px rgba(22, 163, 74, 0.12);
    transform: translateY(-1px);
}

.farm-list-card.active {
    border-color: #16a34a;
    background: #f0fdf4;
    box-shadow: 0 2px 10px rgba(22, 163, 74, 0.18);
}

.farm-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.farm-card-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    background: #f3f4f6;
    flex-shrink: 0;
}

.farm-card-logo-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: linear-gradient(135deg, #d4e0c8 0%, #b8c5a8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #4b7c3a;
    font-weight: 700;
    font-size: 16px;
}

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

.farm-card-name {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.farm-card-location-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.farm-card-location {
    font-size: 12px;
    color: #6b7280;
}

.farm-card-distance {
    font-size: 11px;
    font-weight: 600;
    color: #4285F4;
    background: #eff6ff;
    padding: 1px 6px;
    border-radius: 8px;
    white-space: nowrap;
}

.farm-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
    flex-shrink: 0;
}

.farm-type-badge.farmsource {
    background: #dcfce7;
    color: #166534;
}

.farm-type-badge.partner,
.farm-type-badge.local {
    background: #dbeafe;
    color: #1e40af;
}

.farm-card-description {
    font-size: 12px;
    color: #4b5563;
    margin-top: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.farm-card-specialties {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.farm-card-specialty-tag {
    font-size: 10px;
    font-weight: 500;
    color: #92400e;
    background: #fffbeb;
    padding: 1px 6px;
    border-radius: 6px;
    white-space: nowrap;
}

.farm-card-specialty-more {
    font-size: 10px;
    font-weight: 500;
    color: #6b7280;
    padding: 1px 4px;
}

/* ── Specialty Filter Chips ──────────────────────────────────────── */

.specialty-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.specialty-filter-row:empty {
    display: none;
}

.specialty-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.specialty-chip:hover {
    border-color: #d97706;
    color: #92400e;
}

.specialty-chip.active {
    background: #fffbeb;
    border-color: #d97706;
    color: #92400e;
    font-weight: 600;
}

/* ── Distance Filter ─────────────────────────────────────────────── */

.filter-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Map Canvas ───────────────────────────────────────────────────── */

.farm-map-canvas {
    flex: 1;
    position: relative;
}

.farm-map-canvas #farm-map {
    width: 100%;
    height: 100%;
}

/* ── InfoWindow ───────────────────────────────────────────────────── */

.map-info-window {
    max-width: 300px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.map-info-window .info-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.map-info-window .info-hero {
    width: 100%;
    height: 130px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 10px;
}

.map-info-window .info-name {
    font-weight: 700;
    font-size: 15px;
    color: #1f2937;
    margin: 0;
    line-height: 1.3;
}

.map-info-window .info-location {
    font-size: 12px;
    color: #6b7280;
    margin: 4px 0;
}

.map-info-window .info-distance {
    font-size: 11px;
    font-weight: 600;
    color: #4285F4;
    background: #eff6ff;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.map-info-window .info-story {
    font-size: 12px;
    color: #4b5563;
    line-height: 1.5;
    margin: 8px 0;
    max-height: 54px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.map-info-window .info-specialties {
    font-size: 11px;
    color: #92400e;
    background: #fffbeb;
    padding: 4px 8px;
    border-radius: 6px;
    margin: 6px 0;
    line-height: 1.4;
}

.map-info-window .info-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 7px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s, transform 0.15s;
}

.map-info-window .info-action:hover {
    transform: translateY(-1px);
}

.map-info-window .info-action.farmsource {
    background: #16a34a;
    color: #fff;
}

.map-info-window .info-action.farmsource:hover {
    background: #15803d;
}

.map-info-window .info-action.partner,
.map-info-window .info-action.local {
    background: #2563eb;
    color: #fff;
}

.map-info-window .info-action.partner:hover,
.map-info-window .info-action.local:hover {
    background: #1d4ed8;
}

/* ── Loading & Empty States ───────────────────────────────────────── */

.farm-map-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: #f3f4f6;
}

.farm-map-empty {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.farm-map-empty-icon {
    width: 48px;
    height: 48px;
    background: #f3f4f6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}

/* ── Mobile Responsive ────────────────────────────────────────────── */

@media (max-width: 768px) {
    .farm-map-container {
        flex-direction: column-reverse;
    }

    .farm-map-sidebar {
        width: 100% !important;
        min-width: 100% !important;
        height: 40vh;
        min-height: 200px;
        border-right: none;
        border-top: 1px solid #e5e7eb;
    }

    .farm-map-container.sidebar-collapsed .farm-map-sidebar {
        height: 48px;
        min-height: 48px;
        width: 100% !important;
        min-width: 100% !important;
    }

    .sidebar-toggle-btn {
        display: none;
    }

    .farm-map-canvas {
        height: 60vh;
    }

    .sidebar-header {
        padding: 10px 12px 8px;
        gap: 8px;
    }

    .type-filter-row {
        flex-wrap: wrap;
    }

    .filter-controls-row {
        flex-wrap: wrap;
    }

    .farm-list-container {
        padding: 4px;
    }

    .farm-list-card {
        padding: 10px;
        margin-bottom: 6px;
    }
}
