/* Copyright (c) 2025 FastNetMon LTD <support@fastnetmon.com>
   SPDX-License-Identifier: Proprietary */

:root {
    --bg-primary: #0f1419;
    --bg-secondary: #1a1f26;
    --bg-card: #242b33;
    --text-primary: #e7e9ea;
    --text-secondary: #8b98a5;
    --accent: #1d9bf0;
    --accent-hover: #1a8cd8;
    --success: #00ba7c;
    --error: #f4212e;
    --border: #2f3336;
    --radius: 12px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), #9b59b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    justify-content: center;
}

.tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.tab:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.tab.active {
    background: var(--accent);
    color: white;
}

/* Search Box */
.search-box {
    display: flex;
    gap: 1rem;
    max-width: 500px;
    margin: 0 auto 2rem;
}

.search-box input {
    flex: 1;
    padding: 1rem 1.5rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-box input::placeholder {
    color: var(--text-secondary);
}

.btn-primary {
    padding: 1rem 2rem;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:active {
    transform: scale(0.98);
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 768px) {
    .card-row {
        grid-template-columns: 1fr;
    }
}

/* Mini Tabs */
.tabs-mini {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab-mini {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.tab-mini:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.tab-mini.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Badge */
.badge {
    background: var(--accent);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Scrollable */
.scrollable {
    max-height: 300px;
    overflow-y: auto;
}

.scrollable::-webkit-scrollbar {
    width: 6px;
}

.scrollable::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

.scrollable::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.info-item {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
}

.info-item label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.info-item .value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.info-item .value.asn-link {
    color: var(--accent);
    cursor: pointer;
}

.info-item .value .prefix-link,
.info-item .value .prefix-link:visited {
    color: var(--accent);
    text-decoration: none;
}

.info-item .value .prefix-link:hover {
    text-decoration: underline;
}

.info-item .value.asn-link:hover {
    text-decoration: underline;
}

/* List Items */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: background 0.2s ease;
}

.list-item:hover {
    background: var(--bg-primary);
}

.list-item .prefix {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    color: var(--success);
}

.list-item .prefix.clickable {
    cursor: pointer;
    transition: color 0.2s ease;
}

.list-item .prefix.clickable:hover {
    color: var(--accent);
    text-decoration: underline;
}

.list-item .asn {
    color: var(--accent);
    cursor: pointer;
}

.list-item .asn:hover {
    text-decoration: underline;
}

/* Paths Container */
.paths-container {
    max-height: 400px;
    overflow-y: auto;
}

.path-entry {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.path-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.path-label {
    font-weight: 600;
    color: var(--accent);
}

.path-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nexthop {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.nexthop strong {
    color: var(--success);
}

.path-updated {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* AS Path */
.as-path {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.as-path .asn-chip {
    background: var(--bg-secondary);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.as-path .asn-chip[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    box-shadow: var(--shadow);
    z-index: 1000;
}

.as-path .asn-chip[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border-width: 4px;
    border-style: solid;
    border-color: var(--bg-card) transparent transparent transparent;
    z-index: 1000;
}

.as-path .asn-chip:hover {
    background: var(--accent);
    color: white;
}

.as-path .asn-chip:last-child {
    background: var(--success);
    color: white;
}

/* Loading */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 20, 25, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--error);
    color: white;
    padding: 1rem 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 1001;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* PeeringDB Section */
.peeringdb-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.peeringdb-section h3 {
    font-size: 1.1rem;
    color: var(--accent);
    margin-bottom: 1rem;
}

.peeringdb-section h4 {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin: 1rem 0 0.75rem;
}

.policy-section {
    margin-top: 1rem;
}

.policy-open {
    color: var(--success);
    font-weight: 600;
}

.policy-selective {
    color: #f0ad4e;
    font-weight: 600;
}

.policy-restrictive {
    color: var(--error);
    font-weight: 600;
}

.info-item.full-width {
    grid-column: 1 / -1;
}

.link {
    color: var(--accent);
    text-decoration: none;
    word-break: break-all;
}

.link:visited {
    color: var(--accent);
}

.link:hover {
    text-decoration: underline;
}

.back-link:visited {
    color: var(--accent);
}

.mono {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.875rem;
}

.notes-section {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.notes-section label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.notes-text {
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.6;
    white-space: pre-wrap;
}

/* IX Items */
.ix-item {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

.ix-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.ix-name {
    font-weight: 600;
    color: var(--text-primary);
}

.ix-speed {
    background: var(--accent);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.ix-details {
    display: flex;
    gap: 0.75rem;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.ix-location {
    color: var(--text-secondary);
}

.ix-rs-peer {
    background: var(--success);
    color: white;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.ix-ips {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
}

.ix-ip {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    color: var(--text-secondary);
}

/* Facility Items */
.fac-item {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

.fac-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.fac-location {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Hidden */
.hidden {
    display: none !important;
}

/* Results */
.results {
    animation: fadeIn 0.3s ease;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.empty-state.show-toggle {
    cursor: pointer;
    color: var(--accent);
    padding: 1rem;
    transition: color 0.2s ease;
}

.empty-state.show-toggle:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* Update Banner */
.update-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(90deg, #f0ad4e, #ec971f);
    color: #000;
    padding: 0.75rem;
    z-index: 1000;
    text-align: center;
}

.update-banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-weight: 600;
}

.spinner-small {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(0, 0, 0, 0.3);
    border-top-color: #000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.update-banner + .container {
    padding-top: 4rem;
}

/* AS Path Visualization Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 20, 25, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-radius: 16px;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 210, 255, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(0, 210, 255, 0.2);
    background: rgba(0, 0, 0, 0.2);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: #00d2ff;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: #e4e4e4;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s ease, transform 0.2s ease;
}

.modal-close:hover {
    color: #ff4757;
    transform: scale(1.1);
}

.modal-body {
    padding: 1.5rem;
}

#aspath-graph {
    height: 600px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid rgba(0, 210, 255, 0.1);
}

.aspath-legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #e4e4e4;
    font-size: 0.875rem;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid;
}

.legend-dot.first-hop {
    background: #ff6b6b;
    border-color: #cc5555;
}

.legend-dot.transit {
    background: #3a7bd5;
    border-color: #2a5a9d;
}

.legend-dot.prepended {
    background: #ffa502;
    border-color: #e67e00;
}

.legend-dot.origin {
    background: #00d2ff;
    border-color: #0099cc;
}

/* Visualization Button */
.btn-viz {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, #3a7bd5, #00d2ff);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3);
}

.btn-viz:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 210, 255, 0.4);
}

.btn-viz:active {
    transform: translateY(0);
}

.btn-viz svg {
    width: 18px;
    height: 18px;
}

/* Visualization Card */
.viz-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1.25rem;
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border);
}

.viz-card-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.viz-card-text strong {
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }

    #aspath-graph {
        height: 400px;
    }

    .aspath-legend {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .viz-card {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}
