/**
 * Miral Map Frontend V8 — Premium Design
 * Font: DM Sans + Outfit
 * Colors: Miral brand with refined palette
 */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --m-primary: #B3284B;
    --m-primary-dark: #8E1F3C;
    --m-primary-glow: rgba(179, 40, 75, 0.12);
    --m-secondary: #626366;
    --m-secondary-light: #7A7D82;
    --m-text: #1A202C;
    --m-text-mid: #4A5568;
    --m-text-light: #94A3B8;
    --m-bg: #F8FAFC;
    --m-bg-warm: #FDF7F8;
    --m-white: #ffffff;
    --m-border: #E8ECF1;
    --m-border-light: #F1F5F9;
    --m-shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
    --m-shadow: 0 4px 16px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
    --m-shadow-lg: 0 12px 40px rgba(0,0,0,0.1), 0 4px 12px rgba(0,0,0,0.04);
    --m-shadow-xl: 0 20px 60px rgba(0,0,0,0.12), 0 8px 20px rgba(0,0,0,0.06);
    --m-radius: 10px;
    --m-radius-lg: 16px;
    --m-radius-xl: 20px;
    --m-transition: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ═══════════════════════════════════════
   CONTAINER
   ═══════════════════════════════════════ */
.miral-map-container {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0;
    color: var(--m-text);
    position: relative;
    -webkit-font-smoothing: antialiased;
}

.miral-map-container * { box-sizing: border-box; }

/* Notice */
.miral-notice {
    padding: 18px 24px;
    border-radius: var(--m-radius);
    margin-bottom: 24px;
    font-size: 14px;
    line-height: 1.6;
}

.miral-notice-error {
    background: linear-gradient(135deg, #FEF2F2, #FEE2E2);
    border-left: 4px solid #DC2626;
    color: #991B1B;
}

.miral-notice a { color: #991B1B; font-weight: 600; text-decoration: underline; }

/* ═══════════════════════════════════════
   HERO HEADER
   ═══════════════════════════════════════ */
.miral-hero {
    background: var(--m-white);
    color: var(--m-text);
    padding: 40px 32px 28px;
    border-radius: var(--m-radius-xl) var(--m-radius-xl) 0 0;
    position: relative;
    overflow: hidden;
    border-bottom: 3px solid var(--m-primary);
}

.miral-hero::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -10%;
    width: 340px;
    height: 340px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(179,40,75,0.06) 0%, transparent 70%);
    pointer-events: none;
}

.miral-hero::after {
    content: '';
    position: absolute;
    bottom: -60%;
    left: -5%;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(98,99,102,0.05) 0%, transparent 70%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 20px;
}

.hero-text h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 26px;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -0.02em;
    color: var(--m-primary);
}

.hero-text p {
    font-size: 14px;
    font-weight: 400;
    margin: 0;
    color: var(--m-secondary);
}

.hero-stats {
    display: flex;
    gap: 24px;
    position: relative;
    z-index: 2;
}

.hero-stat {
    text-align: center;
    min-width: 80px;
}

.hero-stat-number {
    font-family: 'Outfit', sans-serif;
    font-size: 32px;
    font-weight: 800;
    line-height: 1;
    color: var(--m-primary);
}

.hero-stat-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--m-text-mid);
    margin-top: 4px;
}

/* ═══════════════════════════════════════
   FILTERS BAR
   ═══════════════════════════════════════ */
.miral-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 14px 24px;
    background: var(--m-white);
    border-left: 1px solid var(--m-border);
    border-right: 1px solid var(--m-border);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-group label {
    font-weight: 600;
    color: var(--m-text);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.miral-select {
    padding: 10px 44px 10px 16px;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
    border: 2px solid var(--m-border);
    border-radius: var(--m-radius);
    background: var(--m-white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394A3B8' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 16px center;
    appearance: none;
    cursor: pointer;
    transition: all var(--m-transition);
    min-width: 200px;
    color: var(--m-text);
}

.miral-select:hover { border-color: var(--m-primary); }
.miral-select:focus {
    outline: none;
    border-color: var(--m-primary);
    box-shadow: 0 0 0 4px var(--m-primary-glow);
}

/* Legend Pills */
.filter-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--m-text-light);
    cursor: pointer;
    padding: 7px 12px;
    border-radius: 100px;
    border: 1.5px solid transparent;
    background: var(--m-bg);
    transition: all var(--m-transition);
    user-select: none;
}

.legend-item:hover {
    border-color: var(--m-border);
    color: var(--m-text-mid);
    background: var(--m-white);
    transform: translateY(-1px);
    box-shadow: var(--m-shadow-sm);
}

.legend-item.active {
    background: var(--m-white);
    border-color: var(--m-primary);
    color: var(--m-text);
    box-shadow: 0 2px 8px var(--m-primary-glow);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════
   MAP
   ═══════════════════════════════════════ */
#miral-map {
    border-left: 1px solid var(--m-border);
    border-right: 1px solid var(--m-border);
    min-height: 700px;
}

/* Stats Bar */
.miral-stats-bar {
    padding: 14px 24px;
    background: var(--m-bg);
    color: var(--m-text-mid);
    font-size: 13px;
    font-weight: 500;
    border-radius: 0 0 var(--m-radius-xl) var(--m-radius-xl);
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid var(--m-border);
}

.miral-stats-bar svg { color: var(--m-primary); opacity: 0.7; }

/* ═══════════════════════════════════════
   CLUSTER PANEL — Slide-out
   ═══════════════════════════════════════ */
.miral-cluster-panel {
    position: fixed;
    top: 0;
    right: -440px;
    width: 420px;
    height: 100vh;
    background: var(--m-white);
    box-shadow: -8px 0 40px rgba(0,0,0,0.12);
    z-index: 10000;
    transition: right 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'DM Sans', sans-serif;
}

.miral-cluster-panel.open { right: 0; }

.panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    backdrop-filter: blur(2px);
}

.panel-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.panel-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 38px;
    height: 38px;
    border: none;
    background: var(--m-bg);
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--m-text-light);
    transition: all var(--m-transition);
    z-index: 10;
    line-height: 1;
}

.panel-close:hover {
    background: var(--m-primary);
    color: white;
    transform: rotate(90deg);
}

.panel-header {
    padding: 28px 24px 20px;
    border-bottom: 1px solid var(--m-border);
    background: linear-gradient(180deg, var(--m-bg) 0%, var(--m-white) 100%);
}

.panel-header h3 {
    margin: 0 0 4px;
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--m-text);
    padding-right: 48px;
    letter-spacing: -0.01em;
}

.panel-subtitle {
    margin: 0;
    font-size: 13px;
    font-weight: 400;
    color: var(--m-text-light);
}

.panel-sections {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--m-border) transparent;
}

.panel-sections::-webkit-scrollbar { width: 5px; }
.panel-sections::-webkit-scrollbar-track { background: transparent; }
.panel-sections::-webkit-scrollbar-thumb { background: var(--m-border); border-radius: 10px; }

.panel-section {
    margin-bottom: 14px;
    background: var(--m-bg);
    border-radius: var(--m-radius-lg);
    overflow: hidden;
    border: 1px solid var(--m-border-light);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--m-white);
    border-bottom: 1px solid var(--m-border-light);
}

.section-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

.section-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--m-text);
}

.section-count {
    background: var(--m-bg);
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 700;
    color: var(--m-text-mid);
    font-family: 'Outfit', sans-serif;
}

.section-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--m-bg);
    transition: all var(--m-transition);
    text-decoration: none;
}

.section-link:hover {
    background: var(--m-white);
    box-shadow: var(--m-shadow);
    transform: scale(1.1);
}

.section-works { padding: 8px; }

.work-item {
    display: block;
    padding: 14px 16px;
    background: var(--m-white);
    border-radius: var(--m-radius);
    margin-bottom: 6px;
    text-decoration: none;
    transition: all var(--m-transition);
    border: 1px solid transparent;
}

.work-item:hover {
    border-color: var(--m-primary);
    transform: translateX(4px);
    box-shadow: var(--m-shadow-sm);
}

.work-item:last-child { margin-bottom: 0; }

.work-title {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--m-text);
    line-height: 1.5;
    margin-bottom: 6px;
}

.work-meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    font-weight: 400;
    color: var(--m-text-light);
}

/* ═══════════════════════════════════════
   INFO WINDOW
   ═══════════════════════════════════════ */
.miral-info-window {
    max-width: 340px;
    padding: 4px;
    font-family: 'DM Sans', sans-serif;
}

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

.info-type {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.info-service {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--m-bg);
    transition: all var(--m-transition);
    text-decoration: none;
}

.info-service:hover { box-shadow: var(--m-shadow); transform: scale(1.1); }

.info-title {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: var(--m-text);
    margin: 0 0 10px 0;
    line-height: 1.4;
    letter-spacing: -0.01em;
}

.info-excerpt {
    font-size: 13px;
    font-weight: 400;
    color: var(--m-text-mid);
    margin: 0 0 14px 0;
    line-height: 1.65;
}

.info-meta {
    display: flex;
    gap: 16px;
    font-size: 11px;
    font-weight: 500;
    color: var(--m-text-light);
    margin-bottom: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--m-border-light);
}

.info-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: white !important;
    padding: 11px 22px;
    border-radius: var(--m-radius);
    font-weight: 600;
    font-size: 13px;
    text-decoration: none !important;
    transition: all var(--m-transition);
}

.info-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--m-shadow-lg);
    filter: brightness(1.08);
}

/* Google Maps overrides */
.gm-style-iw { max-width: 400px !important; }
.gm-style-iw-c {
    padding: 20px !important;
    border-radius: var(--m-radius-lg) !important;
    box-shadow: var(--m-shadow-xl) !important;
}
.gm-style-iw-d { overflow: auto !important; max-height: 420px !important; }
.gm-style-iw-c button.gm-ui-hover-effect {
    top: 10px !important;
    right: 10px !important;
    width: 32px !important;
    height: 32px !important;
    background: var(--m-bg) !important;
    border-radius: 50% !important;
}

/* ═══════════════════════════════════════
   ARTICLES SECTION
   ═══════════════════════════════════════ */
.miral-articles-section {
    margin-top: 56px;
}

.articles-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.articles-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: 'Outfit', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--m-text);
    margin: 0;
    letter-spacing: -0.02em;
}

.articles-title svg { color: var(--m-primary); flex-shrink: 0; }

.articles-title-accent {
    display: inline-block;
    width: 32px;
    height: 4px;
    background: var(--m-primary);
    border-radius: 2px;
    margin-left: 8px;
}

.miral-articles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

/* Article Card */
.miral-article-card {
    background: var(--m-white);
    border-radius: var(--m-radius-lg);
    border: 1px solid var(--m-border);
    padding: 24px;
    transition: all var(--m-transition);
    position: relative;
    overflow: hidden;
}

.miral-article-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--m-border-light);
    transition: all var(--m-transition);
}

.miral-article-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--m-shadow-lg);
    border-color: transparent;
}

.miral-article-card:hover::before {
    height: 3px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.card-service {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--m-bg);
    transition: all var(--m-transition);
    text-decoration: none;
}

.card-service:hover { box-shadow: var(--m-shadow); transform: scale(1.1); }

.card-image-link { display: block; margin: 0 -20px; overflow: hidden; max-height: 150px; }
.card-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}
.miral-article-card:hover .card-image { transform: scale(1.05); }
.card-image-link + .card-title { margin-top: 14px; }

.card-title {
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.5;
    margin: 0 0 10px;
    letter-spacing: -0.01em;
}

.card-title a {
    color: var(--m-text);
    text-decoration: none;
    transition: color var(--m-transition);
}

.card-title a:hover { color: var(--m-primary); }

.card-excerpt {
    font-size: 13px;
    font-weight: 400;
    color: var(--m-text-mid);
    line-height: 1.65;
    margin: 0 0 16px;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 500;
    color: var(--m-text-light);
    padding-top: 14px;
    border-top: 1px solid var(--m-border-light);
    margin-bottom: 16px;
}

.card-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    transition: all var(--m-transition);
}

.card-link:hover {
    gap: 10px;
}

.card-link svg {
    transition: transform var(--m-transition);
}

.card-link:hover svg { transform: translateX(3px); }

/* Load More */
.miral-load-more-container {
    text-align: center;
    margin-top: 48px;
}

.miral-load-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 44px;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--m-primary);
    background: var(--m-white);
    border: 2px solid var(--m-primary);
    border-radius: 100px;
    cursor: pointer;
    transition: all var(--m-transition);
    min-width: 240px;
}

.miral-load-more-btn:hover:not(:disabled) {
    background: var(--m-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--m-primary-glow);
}

.miral-load-more-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: var(--m-border);
    color: var(--m-text-light);
}

.spinner-small {
    width: 18px;
    height: 18px;
    border: 2px solid var(--m-border);
    border-top-color: var(--m-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Loading */
.loading-spinner {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px;
    color: var(--m-text-light);
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--m-border);
    border-top-color: var(--m-primary);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin-bottom: 16px;
}

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

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px;
    color: var(--m-text-light);
    font-size: 14px;
}

/* ═══════════════════════════════════════
   ANIMATIONS (staggered card entrance)
   ═══════════════════════════════════════ */
@keyframes cardFadeIn {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

.miral-article-card {
    animation: cardFadeIn 0.5s ease both;
}

.miral-article-card:nth-child(1) { animation-delay: 0.05s; }
.miral-article-card:nth-child(2) { animation-delay: 0.1s; }
.miral-article-card:nth-child(3) { animation-delay: 0.15s; }
.miral-article-card:nth-child(4) { animation-delay: 0.2s; }
.miral-article-card:nth-child(5) { animation-delay: 0.25s; }
.miral-article-card:nth-child(6) { animation-delay: 0.3s; }

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 1024px) {
    .miral-articles-grid { grid-template-columns: repeat(2, 1fr); }
    .miral-cluster-panel { width: 380px; right: -400px; }
    .hero-stats { gap: 16px; }
}

@media (max-width: 768px) {
    .miral-map-container { padding: 0; }

    .miral-hero {
        padding: 28px 20px 22px;
        border-radius: var(--m-radius-lg) var(--m-radius-lg) 0 0;
    }

    .hero-content { flex-direction: column; align-items: flex-start; }

    .hero-text h2 { font-size: 22px; }

    .hero-stats { gap: 20px; }

    .miral-filters {
        flex-direction: column;
        align-items: stretch;
        padding: 14px 16px;
    }

    .filter-group { flex-direction: column; align-items: stretch; }
    .miral-select { width: 100%; }
    .filter-legend { justify-content: center; }

    #miral-map { min-height: 480px; }

    .miral-articles-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .miral-cluster-panel {
        width: 100%;
        right: -100%;
    }

    .miral-articles-section { margin-top: 36px; }
    .articles-title { font-size: 19px; }

    .miral-stats-bar {
        border-radius: 0 0 var(--m-radius-lg) var(--m-radius-lg);
    }
}

@media (max-width: 480px) {
    .legend-item { padding: 5px 8px; font-size: 11px; }
    .legend-label { display: none; }
    .miral-article-card { padding: 18px; }
    .hero-stat-number { font-size: 26px; }
}

/* ═══════════════════════════════════════════
   Facebook Source Badges
   ═══════════════════════════════════════════ */
.card-header-right,
.info-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}
.card-fb-badge,
.info-fb-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
    transition: opacity 0.2s;
}
.card-fb-badge:hover,
.info-fb-icon:hover {
    opacity: 1;
}
.miral-fb-card {
    border-left: 3px solid #1877F2;
}
.miral-fb-card .card-link {
    color: #1877F2 !important;
}
