/* ==========================================================
   VisualRoute - Modern NOC Dark Theme Stylesheet
   ========================================================== */

:root {
    --bg-main: #0a0e17;
    --bg-card: #111827;
    --bg-card-hover: #172236;
    --bg-input: #0d131f;
    --border-color: #1f293d;
    --border-focus: #3b82f6;

    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;

    --color-primary: #3b82f6;
    --color-primary-glow: rgba(59, 130, 246, 0.4);
    --color-accent: #06b6d4;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-orange: #f97316;
    --color-danger: #ef4444;
    --color-purple: #a855f7;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.4);
}

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

body.dark-theme {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 1.25rem 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    gap: 1.25rem;
}

/* ================= Navbar ================= */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    box-shadow: 0 0 15px var(--color-primary-glow);
}

.logo-text h1 {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-text h1 span {
    color: var(--color-accent);
}

.badge-vps {
    font-size: 0.7rem;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
    margin-left: 6px;
}

.vps-status-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(13, 19, 31, 0.8);
    border: 1px solid var(--border-color);
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-md);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-indicator.online {
    background-color: var(--color-success);
    box-shadow: 0 0 8px var(--color-success);
}

.status-indicator.offline {
    background-color: var(--color-danger);
    box-shadow: 0 0 8px var(--color-danger);
}

.vps-details {
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
}

.vps-label {
    color: var(--text-dim);
    font-size: 0.7rem;
}

.vps-value {
    color: var(--text-main);
    font-weight: 600;
    font-family: var(--font-mono);
}

/* ================= Cards & General Sections ================= */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-main);
}

.card-title i {
    color: var(--color-accent);
}

/* ================= Control Panel ================= */
.trace-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.host-input-group {
    flex: 1;
    min-width: 280px;
}

.input-group label, .input-group-small label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

input[type="text"], input[type="number"], select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s ease;
    width: 100%;
}

input[type="text"]:focus, input[type="number"]:focus, select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px var(--color-primary-glow);
}

.btn-clear {
    position: absolute;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
}

.btn-clear:hover {
    color: var(--text-main);
}

.input-group-small {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    width: 130px;
}

.action-buttons {
    display: flex;
    gap: 0.6rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    transform: translateY(-1px);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.25);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-tool {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
}

.btn-tool:hover {
    color: var(--text-main);
    border-color: var(--color-primary);
}

/* Quick presets */
.quick-presets {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px dashed var(--border-color);
    flex-wrap: wrap;
}

.preset-title {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-weight: 600;
}

.preset-chips {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chip {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chip:hover {
    background: var(--bg-card-hover);
    color: var(--color-accent);
    border-color: var(--color-accent);
}

/* ================= Metrics Grid ================= */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.9rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-card);
}

.metric-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}

.metric-icon.blue { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.metric-icon.green { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.metric-icon.purple { background: rgba(168, 85, 247, 0.15); color: #c084fc; }
.metric-icon.orange { background: rgba(249, 115, 22, 0.15); color: #fb923c; }
.metric-icon.cyan { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }

.metric-data {
    display: flex;
    flex-direction: column;
}

.metric-title {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-weight: 500;
}

.metric-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    font-family: var(--font-mono);
    margin-top: 2px;
}

/* ================= Map Section ================= */
.map-section {
    position: relative;
    padding-bottom: 1.25rem;
}

.map-canvas {
    height: 480px;
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: #06090e;
    z-index: 1;
}

/* Leaflet Custom Marker & Popup Styles */
.custom-hop-marker {
    background: transparent;
    border: none;
}

.marker-node {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #111827;
    border: 2px solid #3b82f6;
    color: #ffffff;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.6);
    position: relative;
    transition: transform 0.2s ease;
}

.marker-node:hover {
    transform: scale(1.25);
    z-index: 999;
}

.marker-origin {
    border-color: #10b981;
    background: #064e3b;
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.8);
}

.marker-target {
    border-color: #ef4444;
    background: #7f1d1d;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.8);
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.8); }
    70% { box-shadow: 0 0 0 14px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.leaflet-popup-content-wrapper {
    background: #111827 !important;
    color: #f3f4f6 !important;
    border: 1px solid #1f293d;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-card);
    font-family: var(--font-main);
}

.leaflet-popup-tip {
    background: #111827 !important;
    border: 1px solid #1f293d;
}

/* Leaflet Layers Control Dark Theme */
.leaflet-control-layers {
    background: rgba(17, 24, 39, 0.92) !important;
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    color: var(--text-main) !important;
    font-family: var(--font-main) !important;
    font-size: 0.8rem !important;
    box-shadow: var(--shadow-card) !important;
    padding: 6px 10px !important;
}

.leaflet-control-layers-expanded {
    padding: 8px 12px !important;
}

.leaflet-control-layers label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    cursor: pointer;
}

.leaflet-control-layers-toggle {
    background-color: rgba(17, 24, 39, 0.9) !important;
    border-radius: var(--radius-sm);
}

.popup-hop-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8rem;
}

.popup-hop-title {
    font-weight: 700;
    color: var(--color-accent);
    border-bottom: 1px solid #1f293d;
    padding-bottom: 4px;
    margin-bottom: 4px;
}

.popup-hop-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.popup-label {
    color: var(--text-dim);
}

.popup-val {
    font-family: var(--font-mono);
    color: var(--text-main);
    font-weight: 600;
}

/* ================= Hops Table ================= */
.table-responsive {
    overflow-x: auto;
    max-height: 420px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.hops-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.hops-table th {
    background: #0d131f;
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.hops-table td {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid rgba(31, 41, 61, 0.6);
    color: var(--text-main);
    font-family: var(--font-mono);
}

.hops-table tr:hover td {
    background: rgba(23, 34, 54, 0.6);
}

.hop-num-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    font-weight: 700;
}

.hop-origin-badge {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.hop-target-badge {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.latency-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.latency-bar-wrapper {
    flex: 1;
    height: 6px;
    background: #1f293d;
    border-radius: 3px;
    overflow: hidden;
}

.latency-bar {
    height: 100%;
    border-radius: 3px;
}

.latency-fast { background-color: var(--color-success); }
.latency-medium { background-color: var(--color-warning); }
.latency-slow { background-color: var(--color-orange); }
.latency-very-slow { background-color: var(--color-danger); }

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.ok {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.timeout {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-badge.private {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--text-dim);
    gap: 0.75rem;
}

.empty-state i {
    font-size: 2.5rem;
    color: var(--border-color);
}

/* ================= Footer ================= */
.footer {
    text-align: center;
    padding: 1rem;
    color: var(--text-dim);
    font-size: 0.75rem;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

/* ================= Responsive ================= */
@media (max-width: 900px) {
    .app-container {
        padding: 1rem;
    }
    .map-canvas {
        height: 360px;
    }
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
