/* Copyright 2026 AbilitySoft. All rights reserved. */
/* Developed for InstaFreight, Inc. under license agreement. */

/* Countries Tool Styles */

/* ===== INDEX PAGE STYLES ===== */
.countries-page {
    min-height: calc(100vh - 200px);
}

.tools-hero {
    background: linear-gradient(135deg, #b71c1c 0%, #8E0000 100%);
    color: white;
    padding: 3rem 0;
    margin-bottom: 2rem;
}

.hero-title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.hero-subtitle {
    font-size: 1.25rem;
    opacity: 0.95;
    font-weight: 400;
}

/* ══════════════════════════════════════════════════
   COUNTRY CARD — World-Class Premium Design
   ══════════════════════════════════════════════════ */
.country-card {
    background: #ffffff;
    border: 1px solid rgba(15,23,42,0.08);
    border-radius: 20px;
    padding: 0;
    transition: transform 0.28s cubic-bezier(.4,0,.2,1),
                box-shadow 0.28s ease,
                border-color 0.28s ease;
    cursor: pointer;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
}

.country-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, #b71c1c 0%, #d32f2f 50%, #ff6659 100%);
    opacity: 0;
    transition: opacity 0.28s ease;
    z-index: 2;
}

.country-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 48px -8px rgba(183,28,28,0.18), 0 4px 16px rgba(0,0,0,0.08);
    border-color: rgba(183,28,28,0.25);
}

.country-card:hover::before { opacity: 1; }

.country-card.is-active {
    border-color: rgba(183,28,28,0.4);
    box-shadow: 0 0 0 3px rgba(183,28,28,0.1), 0 8px 24px rgba(183,28,28,0.12);
}

/* ── Inner padding wrapper ── */
.cc-inner {
    padding: 1.1rem 1.1rem 0.9rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.countries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.1rem;
    margin-top: 1.5rem;
}

/* ── Flag + header ── */
.cc-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
    min-width: 0;
}

.cc-flag-wrap {
    position: relative;
    flex-shrink: 0;
}

.country-flag {
    width: 60px;
    height: 40px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid rgba(15,23,42,0.1);
    background: #f1f5f9;
    display: block;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.cc-name-block {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.country-title {
    font-size: 0.92rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.country-subtitle {
    color: #64748b;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.cc-iso-badge {
    flex-shrink: 0;
    background: rgba(183,28,28,0.07);
    color: #b71c1c;
    border: 1px solid rgba(183,28,28,0.15);
    border-radius: 8px;
    padding: 0.2rem 0.55rem;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    line-height: 1.4;
    white-space: nowrap;
}

/* ── Meta pills ── */
.country-meta {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 0.7rem;
    min-width: 0;
}

.meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    background: rgba(148,163,184,0.12);
    color: #475569;
    font-weight: 600;
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    max-width: 120px;
    text-overflow: ellipsis;
}

/* ── Stats row ── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 0.35rem;
    margin-bottom: 0.7rem;
}

.stat-tile {
    border-radius: 10px;
    padding: 0.45rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-width: 0;
    overflow: hidden;
    text-align: center;
}

.stat-tile.st-ports   { background: rgba(71,85,105,0.08);  border: 1px solid rgba(71,85,105,0.14);  }
.stat-tile.st-airports{ background: rgba(16,185,129,0.08);  border: 1px solid rgba(16,185,129,0.14);  }
.stat-tile.st-terminals{background: rgba(245,158,11,0.08);  border: 1px solid rgba(245,158,11,0.14);  }
.stat-tile.st-canals  { background: rgba(211,47,47,0.08);  border: 1px solid rgba(211,47,47,0.14);  }

.stat-tile .k {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 700;
    font-size: 0.63rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    overflow: hidden;
    white-space: nowrap;
    line-height: 1;
}

.stat-tile.st-ports    .k { color: #334155; }
.stat-tile.st-airports .k { color: #047857; }
.stat-tile.st-terminals .k{ color: #b45309; }
.stat-tile.st-canals   .k { color: #d32f2f; }

.stat-tile .v {
    font-weight: 900;
    font-size: 0.88rem;
    color: #0f172a;
    line-height: 1;
}

/* ── Quick actions ── */
.quick-actions {
    display: flex;
    gap: 0.35rem;
    margin-top: auto;
    padding-top: 0.65rem;
    flex-wrap: wrap;
}

.quick-actions .qa-btn {
    flex: 1;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    border-radius: 10px;
    padding: 0.4rem 0.5rem;
    border: 1px solid rgba(183,28,28,0.16);
    background: rgba(183,28,28,0.05);
    color: #b71c1c;
    font-weight: 700;
    font-size: 0.72rem;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    text-decoration: none;
    user-select: none;
    white-space: nowrap;
}

.quick-actions .qa-btn:hover {
    background: rgba(183,28,28,0.1);
    border-color: rgba(183,28,28,0.28);
    transform: translateY(-1px);
    color: #b71c1c;
}

.quick-actions .qa-btn.secondary {
    border-color: rgba(15,23,42,0.1);
    background: rgba(15,23,42,0.03);
    color: #475569;
}

.quick-actions .qa-btn.secondary:hover {
    background: rgba(15,23,42,0.06);
    border-color: rgba(15,23,42,0.15);
    color: #1e293b;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    background: rgba(51,65,85, 0.1);
    color: #B71C1C;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
}

.map-wrap {
    position: relative;
    width: 100%;
    height: 600px;
    min-height: 600px; /* Prevent CLS */
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    margin: 2rem 0;
}

#countries_map {
    width: 100%;
    height: 100%;
}

.country-marker-flag {
    position: relative;
    pointer-events: none !important;
}

.maplibregl-marker {
    pointer-events: auto !important;
}

.maplibregl-marker > div {
    pointer-events: auto !important;
}

/* Fast loading map icons - no images */
.country-map-icon {
    background: #B71C1C;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.country-map-marker {
    pointer-events: auto !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.country-map-marker:hover {
    transform: scale(1.3);
    box-shadow: 0 4px 12px rgba(0,0,0,0.6);
    z-index: 1001 !important;
}

.maplibregl-marker .country-map-marker {
    pointer-events: auto !important;
}

.map-legend {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
    z-index: 5;
    max-width: 280px;
    font-size: 0.9rem;
}

.map-legend h6 {
    margin: 0 0 8px 0;
    font-weight: 700;
    font-size: 0.9rem;
    color: #0f172a;
}

.map-legend .item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0;
    color: #475569;
}

.map-legend .dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.filters-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    align-items: flex-end;
}

.filters-row .form-select,
.filters-row .form-control {
    min-width: 200px;
}

.result-count {
    font-size: 0.9rem;
    color: #64748b;
    font-weight: 500;
}

/* Map click hint */
.map-click-hint {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(51,65,85, 0.95);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 10;
    max-width: 250px;
    animation: fadeInDown 0.5s ease;
}

.map-click-hint i {
    margin-right: 8px;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Make map cursor pointer to indicate clickability */
#countries_map canvas {
    cursor: pointer !important;
}

/* ===== DETAIL PAGE STYLES ===== */
.country-detail-page {
    min-height: calc(100vh - 200px);
}

.country-hero {
    background: linear-gradient(135deg, #090d16 0%, #111827 50%, #1e1b4b 100%);
    color: white;
    padding: 3rem 0;
    margin-bottom: 2rem;
}

/* ── Map offline placeholder ───────────────────────────────────────────── */
.map-offline-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 100%);
    border-radius: 12px;
    text-align: center;
    padding: 2rem;
    color: #64748b;
}

.map-offline-placeholder i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #94a3b8;
}

.map-offline-placeholder h5 {
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.map-offline-placeholder p {
    max-width: 360px;
    margin: 0;
    font-size: 0.9rem;
}

/* ── Premium Tab Navigation ─────────────────────────────────────────────── */

/* Glassmorphic card header that houses the tab list */
.card-header:has(.premium-nav-pills) {
    background: rgba(248, 250, 252, 0.85) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
    position: sticky;
    top: 0;
    z-index: 20;
}

/* Hide the horizontal scrollbar while keeping scroll functionality */
.premium-nav-pills {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    white-space: nowrap;
    scrollbar-width: none;        /* Firefox */
    -ms-overflow-style: none;     /* IE/Edge */
    padding: 0.15rem 0;
    gap: 0.35rem !important;
    -webkit-overflow-scrolling: touch;
}

.premium-nav-pills::-webkit-scrollbar {
    display: none;                /* Chrome/Safari */
}

/* Tab button base */
.premium-nav-pills .nav-link {
    white-space: nowrap;
    font-size: 0.875rem;
    letter-spacing: 0.01em;
    border-radius: 10px !important;
    padding: 0.5rem 1.1rem !important;
    color: #475569;
    transition: background 0.2s ease, color 0.2s ease,
                box-shadow 0.2s ease, transform 0.15s ease;
    border: 1px solid transparent !important;
}

.premium-nav-pills .nav-link:hover:not(.active) {
    background: rgba(51,65,85, 0.06) !important;
    color: #334155;
    border-color: rgba(51,65,85, 0.12) !important;
    transform: translateY(-1px);
}

.premium-nav-pills .nav-link.active {
    background: linear-gradient(135deg,
        rgba(183,28,28, 0.1) 0%,
        rgba(51,65,85, 0.08) 100%) !important;
    color: #B71C1C !important;
    border-color: rgba(183,28,28, 0.2) !important;
    box-shadow: 0 4px 14px rgba(183,28,28, 0.12),
                0 1px 3px rgba(0, 0, 0, 0.06) !important;
    font-weight: 700;
}

/* Smooth fade between tab panes */
.tab-content .tab-pane {
    animation: none;
}

.tab-content .tab-pane.fade {
    transition: opacity 0.22s ease;
}

.tab-content .tab-pane.fade.show {
    opacity: 1;
}

.country-overview-card {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.country-flag-large {
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.info-card {
    background: #f8fafc;
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid rgba(0,0,0,0.06);
}

.info-card h6 {
    color: #64748b;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.info-card .value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
}

.section-tab {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    /* Prevent CLS - reserve space */
    min-height: 200px;
}

.section-tab h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-tabs {
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 2rem;
    display: flex;
    flex-wrap: wrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.nav-tabs .nav-item {
    flex-shrink: 0;
}

.nav-tabs .nav-link {
    border: none;
    color: #64748b;
    font-weight: 600;
    padding: 1rem 1.5rem;
    white-space: nowrap;
}

.nav-tabs .nav-link.active {
    color: #B71C1C;
    border-bottom: 3px solid #B71C1C;
    background: transparent;
}

.port-card {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    will-change: transform; /* Performance hint */
}

.port-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(51,65,85, 0.2) !important;
}

.port-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #B71C1C 0%, #1e293b 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.port-card:hover::before {
    opacity: 1;
}

.weather-card {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.holiday-card {
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.holiday-card:hover {
    border-left-color: #f59e0b;
    transform: translateX(4px);
}

.time-display {
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading-spinner {
    animation: pulse 1.5s ease-in-out infinite;
}

.economic-stat-card {
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.economic-stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    border-color: rgba(51,65,85, 0.3);
}

.economic-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #B71C1C 0%, #1e293b 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.economic-stat-card:hover::before {
    opacity: 1;
}

.economic-stat-label {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.economic-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.25rem;
}

.economic-stat-unit {
    font-size: 0.875rem;
    color: #94a3b8;
    font-weight: 500;
}

.economic-stat-year {
    font-size: 0.75rem;
    color: #cbd5e1;
    margin-top: 0.5rem;
}

.economic-stat-trend {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    margin-top: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}

.economic-stat-trend.positive {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.economic-stat-trend.negative {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.economic-stat-trend.neutral {
    background: rgba(148, 163, 184, 0.1);
}

/* Chart container - prevent CLS */
#tradeChart {
    min-height: 300px;
    width: 100% !important;
    height: 300px !important;
}

/* Distance map container - prevent CLS */
#distanceMap {
    min-height: 500px;
    width: 100%;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2rem;
    }
    
    .countries-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    
    .map-wrap {
        height: 400px;
        min-height: 400px;
    }
    
    .filters-row {
        flex-direction: column;
    }
    
    .filters-row .form-select,
    .filters-row .form-control {
        width: 100%;
        min-width: auto;
    }
    
    .nav-tabs {
        overflow-x: auto;
        scrollbar-width: thin;
    }
    
    .nav-tabs .nav-link {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 576px) {
    .countries-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Bootstrap compat removed — templates use pure Tailwind */
