/**
 * FlexiBrands Location Grid Widget
 * Modern card-based UI for displaying regions/locations with dispensary counts
 *
 * @package FlexiBrands
 * @since 2.3.0
 */

/* ============================================
   Container & Grid Layout
   ============================================ */

.fb-locations-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
}

.fb-locations-header {
    text-align: center;
    margin-bottom: 40px;
}

.fb-locations-title {
    font-size: 32px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 12px 0;
    line-height: 1.2;
}

.fb-locations-subtitle {
    font-size: 16px;
    color: #6b7280;
    margin: 0;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Flexbox Grid */
.fb-locations-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    justify-content: center;
}

/* ============================================
   Location Card Styles
   ============================================ */

.fb-location-card {
    flex: 0 0 calc(20% - 12px); /* 5 columns */
    min-width: 160px;
    max-width: 240px;
    background: #ffffff;
    border-radius: 12px;
    padding: 18px 20px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #e5e7eb;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.fb-location-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--fb-hero-gradient, linear-gradient(90deg, #10b981 0%, #34d399 100%));
    opacity: 0;
    transition: opacity 0.25s ease;
}

.fb-location-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.10), 0 2px 8px rgba(16, 185, 129, 0.12);
    border-color: var(--fb-hero-primary, #10b981);
}

.fb-location-card:hover::before {
    opacity: 1;
}

.fb-location-card:active {
    transform: translateY(-1px);
}

/* Location Content */
.fb-location-content {
    flex: 1;
}

/* Location Name */
.fb-location-name {
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 6px 0;
    line-height: 1.3;
    transition: color 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fb-location-card:hover .fb-location-name {
    color: var(--fb-hero-primary, #059669);
}

/* Dispensary Count */
.fb-location-count {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

.fb-location-count-number {
    font-weight: 700;
    color: var(--fb-hero-primary, #10b981);
    font-size: 14px;
}

/* Arrow Icon */
.fb-location-arrow {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: all 0.25s ease;
    color: var(--fb-hero-primary, #10b981);
}

.fb-location-card:hover .fb-location-arrow {
    opacity: 1;
    transform: translateY(-50%) translateX(3px);
}

/* ============================================
   Compact Style
   ============================================ */

.fb-locations-grid.compact .fb-location-card {
    flex: 0 0 calc(16.666% - 12px); /* 6 columns */
    min-width: 150px;
    padding: 16px 18px;
}

.fb-locations-grid.compact .fb-location-name {
    font-size: 14px;
}

.fb-locations-grid.compact .fb-location-count {
    font-size: 12px;
}

.fb-locations-grid.compact .fb-location-count-number {
    font-size: 13px;
}

/* ============================================
   Large Style
   ============================================ */

.fb-locations-grid.large .fb-location-card {
    flex: 0 0 calc(25% - 12px); /* 4 columns */
    min-width: 240px;
    padding: 28px 32px;
}

.fb-locations-grid.large .fb-location-name {
    font-size: 20px;
    margin-bottom: 10px;
}

.fb-locations-grid.large .fb-location-count {
    font-size: 14px;
}

.fb-locations-grid.large .fb-location-count-number {
    font-size: 17px;
}

/* ============================================
   Card with Icon Variant
   ============================================ */

.fb-location-card.with-icon {
    flex-direction: row;
    align-items: center;
    gap: 16px;
}

.fb-location-card.with-icon .fb-location-content {
    flex: 1;
    min-width: 0;
}

.fb-location-icon {
    width: 44px;
    height: 44px;
    background: var(--fb-hero-primary-10, rgba(16, 185, 129, 0.1));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fb-hero-primary, #059669);
    font-size: 22px;
    flex-shrink: 0;
    transition: all 0.25s ease;
}

.fb-location-card.with-icon:hover .fb-location-icon {
    background: var(--fb-hero-gradient, linear-gradient(135deg, #10b981 0%, #059669 100%));
    color: #ffffff;
}

/* ============================================
   Featured/Highlighted Cards
   ============================================ */

.fb-location-card.featured {
    background: var(--fb-hero-primary-10, rgba(16, 185, 129, 0.1));
    border-color: var(--fb-hero-primary, #86efac);
}

.fb-location-card.featured .fb-location-name {
    color: var(--fb-hero-primary-dark, #065f46);
}

.fb-location-card.featured .fb-location-count-number {
    color: var(--fb-hero-primary, #047857);
}

/* ============================================
   Loading State
   ============================================ */

.fb-locations-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #6b7280;
    width: 100%;
}

.fb-locations-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--fb-hero-primary, #10b981);
    border-radius: 50%;
    animation: fb-spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes fb-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   Empty State
   ============================================ */

.fb-locations-empty {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

.fb-locations-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* ============================================
   Responsive Design
   ============================================ */

@media screen and (max-width: 1400px) {
    .fb-location-card {
        flex: 0 0 calc(25% - 12px); /* 4 columns */
    }

    .fb-locations-grid.compact .fb-location-card {
        flex: 0 0 calc(20% - 12px); /* 5 columns */
    }

    .fb-locations-grid.large .fb-location-card {
        flex: 0 0 calc(33.333% - 11px); /* 3 columns */
    }
}

@media screen and (max-width: 1100px) {
    .fb-location-card {
        flex: 0 0 calc(25% - 12px); /* 4 columns */
    }

    .fb-locations-grid.compact .fb-location-card {
        flex: 0 0 calc(25% - 12px); /* 4 columns */
    }

    .fb-locations-title {
        font-size: 28px;
    }
}

@media screen and (max-width: 900px) {
    .fb-location-card {
        flex: 0 0 calc(33.333% - 10px); /* 3 columns */
    }

    .fb-locations-grid.compact .fb-location-card {
        flex: 0 0 calc(33.333% - 10px); /* 3 columns */
    }

    .fb-locations-grid.large .fb-location-card {
        flex: 0 0 calc(50% - 8px); /* 2 columns */
    }
}

@media screen and (max-width: 680px) {
    .fb-locations-container {
        padding: 24px 12px;
    }

    .fb-locations-header {
        margin-bottom: 20px;
    }

    .fb-locations-title {
        font-size: 22px;
    }

    .fb-locations-subtitle {
        font-size: 13px;
    }

    .fb-locations-grid {
        gap: 8px;
    }

    /* 3 columns on mobile/tablet */
    .fb-location-card {
        flex: 0 0 calc(33.333% - 6px); /* 3 columns */
        min-width: 100px;
        max-width: none;
        padding: 12px 10px;
    }

    .fb-locations-grid.compact .fb-location-card {
        flex: 0 0 calc(33.333% - 6px); /* 3 columns */
    }

    .fb-locations-grid.large .fb-location-card {
        flex: 0 0 calc(33.333% - 6px); /* 3 columns */
        padding: 14px 12px;
    }

    .fb-location-name {
        font-size: 13px;
        margin-bottom: 3px;
    }

    .fb-location-count {
        font-size: 11px;
    }

    .fb-location-count-number {
        font-size: 12px;
    }

    .fb-location-arrow {
        display: none;
    }
}

@media screen and (max-width: 380px) {
    .fb-locations-grid {
        gap: 6px;
    }

    .fb-location-card,
    .fb-locations-grid.compact .fb-location-card,
    .fb-locations-grid.large .fb-location-card {
        flex: 0 0 calc(33.333% - 4px); /* Still 3 columns */
        padding: 10px 8px;
    }

    .fb-location-name {
        font-size: 12px;
    }

    .fb-location-count {
        font-size: 10px;
    }

    .fb-location-count-number {
        font-size: 11px;
    }
}

/* ============================================
   Animation for Grid Items
   ============================================ */

.fb-location-card {
    animation: fb-fadeInUp 0.4s ease-out backwards;
}

.fb-location-card:nth-child(1) { animation-delay: 0.02s; }
.fb-location-card:nth-child(2) { animation-delay: 0.04s; }
.fb-location-card:nth-child(3) { animation-delay: 0.06s; }
.fb-location-card:nth-child(4) { animation-delay: 0.08s; }
.fb-location-card:nth-child(5) { animation-delay: 0.10s; }
.fb-location-card:nth-child(6) { animation-delay: 0.12s; }
.fb-location-card:nth-child(7) { animation-delay: 0.14s; }
.fb-location-card:nth-child(8) { animation-delay: 0.16s; }
.fb-location-card:nth-child(9) { animation-delay: 0.18s; }
.fb-location-card:nth-child(10) { animation-delay: 0.20s; }
.fb-location-card:nth-child(11) { animation-delay: 0.22s; }
.fb-location-card:nth-child(12) { animation-delay: 0.24s; }
.fb-location-card:nth-child(n+13) { animation-delay: 0.26s; }

@keyframes fb-fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
