/* IP / ASN Intelligence module - polished NOC view */
.intel-body {
    --intel-bg: #070b13;
    --intel-panel: rgba(15, 23, 42, .82);
    --intel-panel-2: rgba(2, 6, 23, .72);
    --intel-border: rgba(148, 163, 184, .16);
    --intel-text: #eef2ff;
    --intel-muted: rgba(226, 232, 240, .64);
    --intel-green: #75bd3f;
    --intel-cyan: #5ac8fa;
    --intel-yellow: #fbbf24;
}

.intelligence-dashboard {
    gap: 18px;
}

.intelligence-dashboard .page-hero,
.intelligence-dashboard .wide-card,
.intelligence-dashboard .metric-card {
    box-shadow: 0 18px 55px rgba(0, 0, 0, .24);
}

.intel-body .button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(255,255,255,.06);
    color: #eef2ff;
    text-decoration: none;
    font-weight: 700;
}

.intel-search-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    border: 1px solid var(--intel-border);
    background:
        radial-gradient(circle at 8% 0%, rgba(117,189,63,.14), transparent 34%),
        radial-gradient(circle at 90% 10%, rgba(90,200,250,.11), transparent 30%),
        var(--intel-panel);
}
.intel-search-card h2 { margin: 0 0 4px; }
.intel-search-card p { margin: 0; color: var(--intel-muted); }
.intel-search-form {
    display: flex;
    gap: 10px;
    width: min(560px, 100%);
}
.intel-search-form input {
    flex: 1;
    min-width: 0;
    border-radius: 15px;
    border: 1px solid rgba(255,255,255,.13);
    background: rgba(7,9,16,.78);
    color: #eef2ff;
    padding: 13px 15px;
    outline: none;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.02);
}
.intel-search-form input:focus {
    border-color: rgba(117,189,63,.54);
    box-shadow: 0 0 0 4px rgba(117,189,63,.10);
}
.intel-search-form button,
.intel-body .toolbar button {
    border: 0;
    border-radius: 14px;
    padding: 12px 18px;
    font-weight: 800;
    color: #07100a;
    background: linear-gradient(135deg, #75bd3f, #b3f56c);
    cursor: pointer;
    box-shadow: 0 12px 28px rgba(117,189,63,.18);
}
.intel-body .toolbar button:disabled {
    opacity: .56;
    cursor: wait;
}

.intel-country-overview {
    border: 1px solid var(--intel-border);
    background:
        linear-gradient(135deg, rgba(15,23,42,.92), rgba(2,6,23,.78)),
        radial-gradient(circle at 40% 0%, rgba(90,200,250,.12), transparent 28%);
}
.country-card-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}
.country-card {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px 12px;
    align-items: center;
    padding: 14px;
    border-radius: 18px;
    border: 1px solid rgba(255,255,255,.10);
    background: linear-gradient(145deg, rgba(255,255,255,.075), rgba(255,255,255,.035));
    overflow: hidden;
}
.country-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 0% 0%, rgba(117,189,63,.16), transparent 42%);
    pointer-events: none;
}
.country-card.unknown::before { background: radial-gradient(circle at 0% 0%, rgba(148,163,184,.14), transparent 42%); }
.country-rank {
    position: absolute;
    top: 10px;
    right: 12px;
    color: rgba(226,232,240,.42);
    font-size: 11px;
    font-weight: 900;
}
.country-bigflag {
    position: relative;
    z-index: 1;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: rgba(2,6,23,.55);
    border: 1px solid rgba(255,255,255,.09);
    font-size: 26px;
}
.country-info,
.country-data { position: relative; z-index: 1; min-width: 0; }
.country-info strong,
.country-data strong {
    display: block;
    color: var(--intel-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.country-info span,
.country-data span {
    color: var(--intel-muted);
    font-size: 12px;
}
.country-data {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,.08);
}
.country-empty {
    grid-column: 1 / -1;
    padding: 16px;
    border-radius: 16px;
    background: rgba(251,191,36,.10);
    border: 1px solid rgba(251,191,36,.20);
    color: #fde68a;
}

.intel-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
.intel-chart-card {
    border: 1px solid var(--intel-border);
    background:
        linear-gradient(180deg, rgba(15,23,42,.92), rgba(2,6,23,.70)),
        radial-gradient(circle at 90% 0%, rgba(117,189,63,.10), transparent 30%);
}
.intel-chart-card .card-header span {
    color: var(--intel-muted);
    font-size: 12px;
    font-weight: 800;
}
.intel-chart-frame {
    width: 100%;
    height: 280px;
    max-height: 280px;
    min-height: 220px;
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid rgba(255,255,255,.08);
    background: #090d17;
}
.intel-chart-frame.small {
    height: 220px;
    max-height: 220px;
}
.intel-chart-frame.detail {
    height: 320px;
    max-height: 320px;
}
.intel-chart-frame canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
}

.intel-link {
    color: #9fe870;
    text-decoration: none;
    font-weight: 800;
}
.intel-link:hover { text-decoration: underline; }

.intel-badge,
.country-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.10);
    color: #e5e7eb;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}
.intel-badge.good { color: #bbf7d0; background: rgba(34,197,94,.14); border-color: rgba(34,197,94,.28); }
.intel-badge.warn { color: #fde68a; background: rgba(245,158,11,.14); border-color: rgba(245,158,11,.28); }
.intel-badge.bad { color: #fecaca; background: rgba(239,68,68,.14); border-color: rgba(239,68,68,.28); }
.country-pill {
    justify-content: flex-start;
    gap: 6px;
    background: rgba(90,200,250,.10);
    border-color: rgba(90,200,250,.18);
    color: #e0f2fe;
}
.country-pill.unknown {
    background: rgba(148,163,184,.10);
    border-color: rgba(148,163,184,.18);
    color: #cbd5e1;
}
.country-flag { font-size: 16px; line-height: 1; }
.country-code { letter-spacing: .03em; }
.country-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.analytics-table-grid .wide-card {
    border: 1px solid var(--intel-border);
    background: var(--intel-panel);
}
.analytics-table th {
    color: rgba(226,232,240,.58);
    font-size: 11px;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.analytics-table td {
    vertical-align: middle;
}
.analytics-table tbody tr:hover {
    background: rgba(255,255,255,.035);
}
.empty-cell {
    padding: 18px !important;
    text-align: center;
}

.intel-detail-card .intel-kv-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}
.intel-kv {
    min-width: 0;
    padding: 14px;
    border-radius: 16px;
    background: rgba(255,255,255,.045);
    border: 1px solid rgba(255,255,255,.08);
}
.intel-kv span {
    display: block;
    margin-bottom: 6px;
    color: rgba(238,242,255,.55);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.intel-kv strong {
    display: block;
    color: #eef2ff;
    overflow-wrap: anywhere;
}

@media (max-width: 1280px) {
    .country-card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .intel-detail-card .intel-kv-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
    .country-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .intel-chart-grid { grid-template-columns: 1fr; }
    .intel-search-card { align-items: stretch; flex-direction: column; }
    .intel-search-form { width: 100%; }
    .intel-chart-frame { height: 240px; max-height: 240px; min-height: 190px; }
    .intel-chart-frame.detail { height: 260px; max-height: 260px; }
    .intel-detail-card .intel-kv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .country-card-grid { grid-template-columns: 1fr; }
    .intel-search-form { flex-direction: column; }
    .country-pill .country-name { display: none; }
    .intel-chart-frame { height: 220px; max-height: 220px; min-height: 190px; }
    .intel-chart-frame.small { height: 190px; max-height: 190px; }
    .intel-chart-frame.detail { height: 230px; max-height: 230px; }
    .intel-detail-card .intel-kv-grid { grid-template-columns: 1fr; }
    .intel-body .toolbar { gap: 6px; }
    .intel-body .toolbar select,
    .intel-body .toolbar button,
    .intel-body .button-link { width: 100%; }
}

/* IP Intelligence UI fix: reliable flags, ASN names and responsive spacing */
.intelligence-dashboard {
    grid-auto-flow: row;
    align-items: start;
}

.intel-search-card {
    min-height: auto;
    align-items: center;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
    margin-bottom: 0;
}

.intel-search-card > div {
    min-width: 260px;
}

.intel-search-form {
    flex: 1 1 420px;
    max-width: 620px;
}

.intel-body .analytics-metrics,
.intelligence-dashboard .analytics-metrics,
.intelligence-dashboard .metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    align-items: stretch;
    width: 100%;
    position: relative;
    z-index: 0;
}

.intelligence-dashboard .metric-card {
    min-width: 0;
    overflow: hidden;
}

.intelligence-dashboard .metric-value,
.intelligence-dashboard .metric-value.small {
    font-size: clamp(30px, 3.4vw, 58px);
    line-height: .98;
    white-space: nowrap;
}

.flag-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    overflow: hidden;
    background: rgba(2,6,23,.48);
    border: 1px solid rgba(255,255,255,.12);
    box-shadow: 0 6px 16px rgba(0,0,0,.16);
}

.flag-wrap.sm,
.flag-fallback.sm {
    width: 28px;
    height: 21px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 900;
}

.flag-wrap.lg,
.flag-fallback.lg {
    width: 50px;
    height: 38px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 900;
}

.flag-wrap img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.flag-fallback {
    display: none;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", system-ui, sans-serif;
    line-height: 1;
}

.flag-fallback.visible,
.flag-wrap.unknown .flag-fallback {
    display: inline-flex;
}

.flag-wrap.unknown {
    background: rgba(148,163,184,.12);
    color: #cbd5e1;
}

.country-bigflag {
    padding: 0;
    background: transparent;
    border: 0;
}

.country-pill {
    max-width: 100%;
    text-align: left;
}

.country-pill .country-name {
    display: inline-block;
    max-width: 180px;
    white-space: nowrap;
}

.country-card-grid {
    grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
}

.country-card {
    min-width: 0;
}

.intel-chart-card,
.intel-chart-frame {
    min-width: 0;
}

.intel-chart-frame {
    height: clamp(230px, 22vw, 320px);
    max-height: 340px;
}

#asnChart {
    min-height: 260px;
}

.asn-company {
    display: inline-block;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
    color: rgba(226,232,240,.66);
}

@media (max-width: 1100px) {
    .intel-chart-grid {
        grid-template-columns: 1fr;
    }
    .intel-search-card {
        align-items: flex-start;
    }
    .intel-search-form {
        max-width: none;
        width: 100%;
    }
}

@media (max-width: 720px) {
    .intel-search-card {
        padding: 16px;
        gap: 14px;
    }
    .intel-search-card > div {
        min-width: 0;
        width: 100%;
    }
    .intel-search-form {
        flex-direction: column;
    }
    .intel-search-form button {
        width: 100%;
    }
    .intelligence-dashboard .metric-value,
    .intelligence-dashboard .metric-value.small {
        font-size: clamp(28px, 9vw, 44px);
    }
    .intel-chart-frame {
        height: 240px;
        min-height: 220px;
    }
    .country-pill .country-name {
        max-width: 115px;
    }
}


/* Canvas chart hover tooltip */
.intel-chart-tooltip {
    position: fixed;
    z-index: 9999;
    width: min(340px, calc(100vw - 28px));
    padding: 12px 13px;
    border-radius: 14px;
    border: 1px solid rgba(148,163,184,.24);
    background: rgba(2,6,23,.96);
    box-shadow: 0 18px 48px rgba(0,0,0,.44);
    color: #eef2ff;
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity .12s ease, transform .12s ease;
    backdrop-filter: blur(10px);
}
.intel-chart-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}
.intel-chart-tooltip .tip-title {
    margin-bottom: 8px;
    color: #fff;
    font-weight: 900;
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.intel-chart-tooltip .tip-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    border-top: 1px solid rgba(255,255,255,.07);
}
.intel-chart-tooltip .tip-row span {
    color: rgba(226,232,240,.62);
}
.intel-chart-tooltip .tip-row strong {
    color: #e5f9d7;
    text-align: right;
}
.intel-chart-tooltip .tip-action {
    margin-top: 8px;
    color: rgba(90,200,250,.86);
    font-weight: 800;
}
