/**
 * Market Insights Styles - Map, Charts, and Components
 */

/* Map Container */
.map-container {
    width: 100%;
    height: 500px;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    background: #f8f9fa;
}

.map-container-fullpage {
    height: calc(100vh - 300px);
    min-height: 500px;
}

/* Map Tooltip - Professional Card Design */
.market-insights-tooltip {
    background: white;
    border: none;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 0;
    min-width: 260px;
    max-width: 320px;
    font-family: inherit;
    z-index: 1000;
}

.market-insights-tooltip::before {
    border-top-color: white !important;
}

.leaflet-tooltip-top.market-insights-tooltip::before {
    border-top-color: white;
}

.market-insights-tooltip .leaflet-tooltip-content {
    padding: 0;
}

.tooltip-header {
    font-size: 1.05rem;
    font-weight: 600;
    padding: 14px 16px 10px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.tooltip-header strong {
    color: #1f2937;
}

.tooltip-header .country-code {
    font-size: 0.75rem;
    color: #6c757d;
    font-weight: 500;
    background: white;
    padding: 2px 8px;
    border-radius: 10px;
    border: 1px solid #dee2e6;
}

.tooltip-section {
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.tooltip-section:last-of-type {
    border-bottom: none;
}

.tooltip-section.market-data {
    background: linear-gradient(180deg, #f0f9ff 0%, white 100%);
}

.tooltip-section.tt-status {
    background: white;
}

.tooltip-section.no-data {
    background: #fafafa;
    padding: 12px 16px;
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 0.85rem;
    gap: 12px;
}

.tooltip-row.small {
    font-size: 0.8rem;
    color: #6c757d;
    padding: 2px 0;
    justify-content: center;
}

.tooltip-row .label {
    color: #64748b;
    font-weight: 500;
}

.tooltip-row .value {
    font-weight: 700;
    color: #1f2937;
}

.tooltip-row .value.positive {
    color: #16a34a;
    background: rgba(22, 163, 74, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
}

.tooltip-row .value.negative {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
}

.tooltip-divider {
    border-top: 1px dashed #e5e7eb;
    margin: 8px 0;
}

.tooltip-footer {
    font-size: 0.8rem;
    font-weight: 600;
    color: #0d6efd;
    text-align: center;
    padding: 10px 16px;
    background: linear-gradient(180deg, white 0%, #f8fafc 100%);
    border-radius: 0 0 12px 12px;
    border-top: 1px solid #e9ecef;
}

.tooltip-footer::before {
    content: "\f054";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    margin-right: 6px;
    font-size: 0.7rem;
}

/* Tooltip badges */
.tooltip-section .badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 6px;
    letter-spacing: 0.02em;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.badge-active {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
}

.badge-pilot {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #1f2937;
}

.badge-in-progress {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    color: white;
}

.badge-planned {
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
    color: white;
}

.badge-system {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
}

/* Map Legend */
.map-legend {
    background: white;
    padding: 12px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    font-size: 0.85rem;
}

.legend-title {
    font-weight: 600;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e9ecef;
}

.legend-item {
    display: flex;
    align-items: center;
    padding: 3px 0;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-right: 8px;
    border: 2px solid white;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

/* View Toggle Buttons */
.view-toggle-container {
    display: flex;
    gap: 0.5rem;
}

.view-toggle-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #dee2e6;
    background: white;
    color: #495057;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.view-toggle-btn:hover {
    background: #f8f9fa;
    border-color: #0d6efd;
    color: #0d6efd;
}

.view-toggle-btn.active {
    background: #0d6efd;
    border-color: #0d6efd;
    color: white;
}

.view-toggle-btn i {
    font-size: 0.9rem;
}

/* Chart Containers */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-container-lg {
    height: 400px;
}

/* Market Insight Cards */
.market-card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: transform 0.2s, box-shadow 0.2s;
}

.market-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
}

.market-card .card-header {
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
    color: white;
    border-radius: 0.75rem 0.75rem 0 0 !important;
    padding: 1rem 1.25rem;
}

.market-card .flag-icon {
    font-size: 2rem;
    margin-right: 0.75rem;
}

.market-stat {
    text-align: center;
    padding: 1rem;
}

.market-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #0d6efd;
    line-height: 1.2;
}

.market-stat-label {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

.market-stat-change {
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 0.25rem;
}

.market-stat-change.positive {
    color: #28a745;
}

.market-stat-change.negative {
    color: #dc3545;
}

/* Growth Arrow */
.growth-arrow {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.growth-arrow.up {
    color: #28a745;
}

.growth-arrow.down {
    color: #dc3545;
}

/* Composition Bar */
.composition-bar {
    display: flex;
    height: 24px;
    border-radius: 4px;
    overflow: hidden;
    background: #e9ecef;
}

.composition-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    transition: width 0.5s ease;
}

.composition-segment.local {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.composition-segment.imports {
    background: linear-gradient(135deg, #0d6efd 0%, #6610f2 100%);
}

/* Infrastructure Grid */
.infrastructure-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.infrastructure-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 0.5rem;
}

.infrastructure-item i {
    font-size: 1.25rem;
    color: #0d6efd;
    width: 30px;
    text-align: center;
}

.infrastructure-item .value {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.2;
}

.infrastructure-item .label {
    font-size: 0.75rem;
    color: #6c757d;
}

/* Important Announcement Modal/Banner */
.important-announcement-modal .modal-content {
    border: none;
    border-radius: 1rem;
    overflow: hidden;
}

.important-announcement-modal .modal-header {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    border: none;
    padding: 1rem 1.5rem;
}

.important-announcement-modal .modal-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.important-announcement-modal .btn-close {
    filter: brightness(0) invert(1);
}

.important-announcement-banner {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
    border-left: 4px solid #ffc107;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.important-announcement-banner .announcement-content {
    flex: 1;
}

.important-announcement-banner .announcement-title {
    font-weight: 600;
    color: #856404;
    margin-bottom: 0.25rem;
}

.important-announcement-banner .announcement-text {
    color: #664d03;
    font-size: 0.9rem;
}

.important-announcement-banner .btn-close-banner {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #856404;
    cursor: pointer;
    padding: 0.5rem;
}

/* Mobile Responsiveness */
@media (max-width: 991px) {
    .map-container {
        height: 400px;
    }

    .map-container-fullpage {
        height: 350px;
    }

    .chart-container {
        height: 250px;
    }

    .infrastructure-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .map-container {
        height: 350px;
    }

    .view-toggle-container {
        flex-wrap: wrap;
    }

    .view-toggle-btn {
        flex: 1;
        justify-content: center;
        padding: 0.5rem;
    }

    .market-stat-value {
        font-size: 1.5rem;
    }

    /* Mobile-optimized tooltip */
    .market-insights-tooltip {
        min-width: 200px;
        max-width: 280px;
        border-radius: 10px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    }

    .tooltip-header {
        padding: 10px 12px 8px;
        font-size: 0.95rem;
    }

    .tooltip-header .country-code {
        font-size: 0.7rem;
        padding: 2px 6px;
    }

    .tooltip-section {
        padding: 8px 12px;
    }

    .tooltip-row {
        font-size: 0.8rem;
        padding: 3px 0;
        gap: 8px;
    }

    .tooltip-row .value.positive,
    .tooltip-row .value.negative {
        padding: 2px 6px;
    }

    .tooltip-footer {
        font-size: 0.75rem;
        padding: 8px 12px;
    }

    .tooltip-footer::before {
        content: none;  /* Hide arrow icon on mobile */
    }

    .tooltip-section .badge {
        font-size: 0.7rem;
        padding: 4px 8px;
    }

    .map-legend {
        font-size: 0.75rem;
        padding: 8px 10px;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .market-insights-tooltip {
        min-width: 180px;
        max-width: 240px;
    }

    .tooltip-header {
        padding: 8px 10px 6px;
        font-size: 0.9rem;
    }

    .tooltip-section {
        padding: 6px 10px;
    }

    .tooltip-row {
        font-size: 0.75rem;
        flex-wrap: wrap;
    }

    .map-legend {
        font-size: 0.7rem;
        padding: 6px 8px;
    }

    .legend-color {
        width: 10px;
        height: 10px;
    }
}

/* RTL Support */
[dir="rtl"] .tooltip-row {
    flex-direction: row-reverse;
}

[dir="rtl"] .tooltip-header {
    flex-direction: row-reverse;
}

[dir="rtl"] .tooltip-footer::before {
    content: "\f053";  /* Left arrow for RTL */
    margin-right: 0;
    margin-left: 6px;
}

[dir="rtl"] .legend-color {
    margin-right: 0;
    margin-left: 8px;
}

[dir="rtl"] .infrastructure-item {
    flex-direction: row-reverse;
}

[dir="rtl"] .market-card .flag-icon {
    margin-right: 0;
    margin-left: 0.75rem;
}

[dir="rtl"] .important-announcement-banner {
    border-left: none;
    border-right: 4px solid #ffc107;
}

[dir="rtl"] .composition-bar {
    flex-direction: row-reverse;
}

/* Animation for chart loading */
@keyframes chartFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chart-container canvas {
    animation: chartFadeIn 0.5s ease-out;
}

/* Country Label on Map */
.country-label {
    background: transparent !important;
    border: none !important;
}

.country-label .label-text {
    font-size: 11px;
    font-weight: 700;
    color: #1f2937;
    text-align: center;
    text-shadow: 1px 1px 2px white, -1px -1px 2px white, 1px -1px 2px white, -1px 1px 2px white;
    pointer-events: none;
}

/* Map container styles */
#regulationMap,
#marketInsightsMap {
    width: 100%;
    height: 100%;
    min-height: 500px;
    background: #f0f4f8;
}

/* Ensure Leaflet container takes full space */
.leaflet-container {
    width: 100% !important;
    height: 100% !important;
    font-family: inherit;
}

/* Circle marker cursor - only clickable markers show pointer */
.leaflet-interactive {
    cursor: default;
}

.leaflet-interactive.clickable {
    cursor: pointer;
}

/* Tooltip enhancements */
.tooltip-header .country-code {
    font-size: 0.8rem;
    color: #6c757d;
    font-weight: normal;
}

.tooltip-section.no-data {
    padding: 4px 0;
}

.tooltip-row.text-muted {
    color: #6c757d;
    font-style: italic;
}

/* Make markers more visible and interactive */
.country-marker {
    transition: all 0.15s ease-out;
}

/* Ensure labels don't block marker interaction */
.country-label {
    pointer-events: none !important;
}
