/* Theme & Variables */
:root {
    --bg-base: #0A0E17;
    /* Very dark slate/blue */
    --bg-surface: #131A28;
    /* Slightly lighter surface */
    --bg-surface-hover: #1A2336;

    --primary: #00F0FF;
    /* Cyan */
    --primary-dim: rgba(0, 240, 255, 0.15);

    --success: #00FF66;
    /* Neon Green */
    --warning: #FFB800;
    /* Yellow */
    --error: #FF0055;
    /* Neon Red */
    --text-main: #FFFFFF;
    --text-muted: #8AA2C0;

    --border: rgba(138, 162, 192, 0.15);

    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius: 8px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-ui);
    line-height: 1.5;
    overflow-x: hidden;
}

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

.space-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.muted {
    color: var(--text-muted);
}

/* Layout */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}

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

.brand h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.top-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Toggle Control */
.toggle-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.toggle-control input {
    display: none;
}

.toggle-track {
    width: 36px;
    height: 20px;
    background: var(--bg-base);
    border-radius: 10px;
    border: 1px solid var(--border);
    position: relative;
    transition: all 0.2s;
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.2s;
}

.toggle-control input:checked+.toggle-track {
    background: var(--primary-dim);
    border-color: var(--primary);
}

.toggle-control input:checked+.toggle-track::after {
    transform: translateX(16px);
    background: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius);
    font-family: var(--font-ui);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--primary);
    color: #000;
    font-weight: 600;
}

.btn-primary:hover {
    box-shadow: 0 0 15px var(--primary-dim);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-main);
    border-color: var(--border);
}

.btn-secondary:hover {
    background-color: var(--bg-surface-hover);
}

.btn-text {
    background: transparent;
    color: var(--primary);
    padding: 0.2rem 0.5rem;
}

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

.btn-sm {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
}

/* Dropdown */
.export-dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 150px;
    display: none;
    z-index: 100;
}

.export-dropdown:hover .dropdown-menu {
    display: flex;
    flex-direction: column;
}

.dropdown-item {
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: var(--bg-surface-hover);
    color: var(--primary);
}

/* Search Section */
.search-section {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: radial-gradient(circle at center, rgba(0, 240, 255, 0.05) 0%, transparent 70%);
}

.search-bar {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    max-width: 700px;
}

.mono-input {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    outline: none;
    transition: all 0.2s;
}

.mono-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-dim);
}

#domain-input {
    flex: 1;
}

select.mono-input {
    cursor: pointer;
    appearance: none;
    padding-right: 2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238AA2C0' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

.expected-input-group {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 700px;
    width: 100%;
}

.expected-input-group input {
    padding: 0.3rem 0.5rem;
    flex: 1;
}

/* Main Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 1.5rem;
    padding: 2rem;
    flex: 1;
}

/* Cards */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0px;
}

/* Stats Cards */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-mono);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

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

.progress-bar-container {
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 2px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    transition: width 1s linear;
    width: 100%;
}

/* Map Area */
.map-card {
    flex: 1;
}

.map-legend {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot.match {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.dot.mismatch {
    background: var(--error);
    box-shadow: 0 0 8px var(--error);
}

.dot.error {
    background: #555;
}

.map-container {
    margin-top: 1rem;
    flex: 1;
    position: relative;
    min-height: 400px;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.02) 0%, transparent 100%);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.map-container svg {
    width: 100%;
    height: 100%;
    opacity: 0.4;
}

.map-node {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #555;
    border: 2px solid var(--bg-surface);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    z-index: 10;
}

.map-node.pinging {
    animation: pulse 1s infinite alternate;
}

.map-node.match {
    background: var(--success);
}

.map-node.mismatch {
    background: var(--error);
}

.map-node.error {
    background: #555;
}

/* Pulse animations for map dots */
@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 0 0 rgba(0, 240, 255, 0.7);
    }

    100% {
        transform: translate(-50%, -50%) scale(1.2);
        box-shadow: 0 0 0 6px rgba(0, 240, 255, 0);
    }
}

/* Tooltip */
.node-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translate(-50%, -10px);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    border: 1px solid var(--border);
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 20;
    font-family: var(--font-mono);
}

.map-node:hover .node-tooltip {
    opacity: 1;
}

/* Results Sidebar */
.results-card {
    height: 100%;
}

.status-badge {
    background: var(--primary-dim);
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.complete {
    background: rgba(0, 255, 102, 0.1);
    border-color: var(--success);
    color: var(--success);
}

.results-table-container {
    margin-top: 1rem;
    overflow-y: auto;
    flex: 1;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.results-table th {
    text-align: left;
    padding: 0.75rem 0.5rem;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    z-index: 5;
}

.results-table td {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
}

.results-table tr:last-child td {
    border-bottom: none;
}

.results-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.res-loc {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-ui);
    font-weight: 500;
}

.flag {
    font-size: 1.1em;
}

.res-val {
    word-break: break-all;
    max-width: 150px;
}

.res-time {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.val-match {
    color: var(--success);
}

.val-mismatch {
    color: var(--error);
}

.val-error {
    color: #555;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    font-family: var(--font-ui);
}

.empty-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--primary);
    color: #000;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Responsive */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto 500px;
    }

    .search-bar {
        flex-direction: column;
        width: 100%;
        max-width: none;
    }

    .stats-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 600px) {
    .topbar {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .stats-cards {
        grid-template-columns: 1fr;
    }
}