/**
 * Sanche Partners — Responsive Grid, Cards, Enriched Map & Filters
 *
 * @package Sanche_MTK_Suite
 */

/* =====================================================
   VARIABLES
   ===================================================== */

:root {
    --sp-primary: #0d6e3f;
    --sp-primary-light: #12914f;
    --sp-bg: #f8f9fa;
    --sp-card-bg: #ffffff;
    --sp-text: #333333;
    --sp-text-muted: #6c757d;
    --sp-border: #e0e0e0;
    --sp-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --sp-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.14);
    --sp-radius: 12px;
    --sp-radius-sm: 8px;
    --sp-transition: 0.25s ease;
}

/* =====================================================
   WRAPPER
   ===================================================== */

.sanche-partners-wrapper {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

/* =====================================================
   TOOLBAR — Filters + Toggle
   ===================================================== */

.sp-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.sp-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.sp-filter-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--sp-border);
    border-radius: 50px;
    background: var(--sp-card-bg);
    color: var(--sp-text);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--sp-transition);
    white-space: nowrap;
}

.sp-filter-btn:hover {
    border-color: var(--sp-primary);
    color: var(--sp-primary);
}

.sp-filter-btn.active {
    background: var(--sp-primary);
    border-color: var(--sp-primary);
    color: #fff;
}

/* Toggle Cards / Map */
.sp-toggle {
    display: flex;
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius-sm);
    overflow: hidden;
}

.sp-toggle-btn {
    padding: 0.5rem 1rem;
    background: var(--sp-card-bg);
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all var(--sp-transition);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.sp-toggle-btn.active {
    background: var(--sp-primary);
    color: #fff;
}

.sp-toggle-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
}

.sp-toggle-btn.active .sp-toggle-badge {
    background: rgba(255, 255, 255, 0.35);
}

/* =====================================================
   CARDS GRID
   ===================================================== */

.sp-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.sp-card {
    background: var(--sp-card-bg);
    border-radius: var(--sp-radius);
    box-shadow: var(--sp-shadow);
    overflow: hidden;
    transition: box-shadow var(--sp-transition), transform var(--sp-transition);
    animation: sp-fade-in 0.3s ease;
}

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

.sp-card.sp-hidden {
    display: none;
}

@keyframes sp-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Card Image */
.sp-card-img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.sp-card-img-placeholder {
    width: 100%;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    color: var(--sp-primary);
    font-size: 2.5rem;
}

/* Card Body */
.sp-card-body {
    padding: 1rem 1.25rem;
    position: relative;
}

.sp-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.sp-card-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--sp-text);
    margin: 0;
    line-height: 1.3;
}

/* Coordinate indicator on card */
.sp-card-has-coords {
    position: absolute;
    top: -12px;
    right: 12px;
    background: var(--sp-primary);
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Category Badge */
.sp-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.sp-badge-hospedagem {
    background: #e3f2fd;
    color: #1565c0;
}

.sp-badge-restaurante {
    background: #fff3e0;
    color: #e65100;
}

.sp-badge-experiencia {
    background: #f3e5f5;
    color: #7b1fa2;
}

.sp-badge-loja {
    background: #fce4ec;
    color: #c62828;
}

.sp-badge-aluguel_carro {
    background: #e8f5e9;
    color: #2e7d32;
}

.sp-badge-taxi {
    background: #fffde7;
    color: #f57f17;
}

.sp-badge-passeio {
    background: #e0f7fa;
    color: #00838f;
}

.sp-badge-default {
    background: #f5f5f5;
    color: #616161;
}

/* Pitch */
.sp-card-pitch {
    font-size: 0.875rem;
    color: var(--sp-text-muted);
    margin: 0.5rem 0 0.75rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Address */
.sp-card-address {
    font-size: 0.8rem;
    color: var(--sp-text-muted);
    margin-bottom: 0.75rem;
}

.sp-card-address::before {
    content: '📍 ';
}

/* Social Links */
.sp-card-links {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-top: 0.75rem;
    border-top: 1px solid var(--sp-border);
}

.sp-card-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: var(--sp-primary);
    text-decoration: none;
    transition: color var(--sp-transition);
}

.sp-card-link:hover {
    color: var(--sp-primary-light);
    text-decoration: underline;
}

/* Highlighted card links */
.sp-card-link-wa {
    color: #25D366;
    font-weight: 600;
}

.sp-card-link-wa:hover {
    color: #128C7E;
}

.sp-card-link-dir {
    color: #4285F4;
    font-weight: 600;
}

.sp-card-link-dir:hover {
    color: #1a73e8;
}

/* =====================================================
   MAP
   ===================================================== */

.sp-map-container {
    display: none;
    height: 500px;
    border-radius: var(--sp-radius);
    overflow: hidden;
    box-shadow: var(--sp-shadow);
    margin-bottom: 1.5rem;
}

.sp-map-container.sp-visible {
    display: block;
}

#sanche-partners-map {
    width: 100%;
    height: 100%;
}

/* =====================================================
   MAP — Custom Markers (L.divIcon)
   ===================================================== */

.sp-marker {
    background: none !important;
    border: none !important;
}

.sp-marker-pin {
    width: 32px;
    height: 32px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    position: relative;
}

.sp-marker-emoji {
    transform: rotate(45deg);
    font-size: 14px;
    line-height: 1;
}

/* =====================================================
   MAP — Enriched Popup
   ===================================================== */

.sp-popup-container .leaflet-popup-content-wrapper {
    padding: 0;
    border-radius: var(--sp-radius);
    overflow: hidden;
    box-shadow: var(--sp-shadow-hover);
}

.sp-popup-container .leaflet-popup-content {
    margin: 0;
    min-width: 220px;
}

.sp-popup-container .leaflet-popup-tip {
    box-shadow: none;
}

.sp-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.sp-popup-img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.sp-popup-body {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sp-popup-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--sp-text);
    line-height: 1.3;
}

.sp-popup-category {
    font-size: 0.75rem;
    color: var(--sp-text-muted);
}

.sp-popup-address {
    font-size: 0.75rem;
    color: var(--sp-text-muted);
    line-height: 1.4;
}

.sp-popup-phone {
    font-size: 0.75rem;
    color: var(--sp-text-muted);
}

.sp-popup-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--sp-border);
}

.sp-popup-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.65rem;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--sp-transition);
    white-space: nowrap;
}

.sp-popup-btn-wa {
    background: #25D366;
    color: #fff;
}

.sp-popup-btn-wa:hover {
    background: #128C7E;
    color: #fff;
}

.sp-popup-btn-dir {
    background: #4285F4;
    color: #fff;
}

.sp-popup-btn-dir:hover {
    background: #1a73e8;
    color: #fff;
}

/* =====================================================
   EMPTY STATE
   ===================================================== */

.sp-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--sp-text-muted);
}

.sp-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.sp-empty-text {
    font-size: 1rem;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {
    .sp-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .sp-filters {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .sp-toggle {
        align-self: flex-end;
    }

    .sp-cards-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .sp-map-container {
        height: 350px;
    }

    .sp-popup-img {
        height: 90px;
    }
}

@media (max-width: 480px) {
    .sanche-partners-wrapper {
        padding: 0 0.5rem;
    }

    .sp-card-img,
    .sp-card-img-placeholder {
        height: 150px;
    }

    .sp-map-container {
        height: 300px;
    }
}