/* ============================================
   DNSViz Frontend - Modern Dark Theme CSS
   Inspired by ui.py ReactPy implementation
   ============================================ */

/* CSS Variables / Design Tokens */
:root {
    /* Dark Theme Colors */
    --bg-primary: #0a0a0b;
    --bg-secondary: #111113;
    --bg-card: #18181b;
    --bg-card-hover: #1f1f23;
    --bg-elevated: #27272a;

    /* Accent Colors */
    --accent-primary: #3b82f6;
    --accent-secondary: #6366f1;
    --accent-cyan: #22d3ee;
    --accent-green: #10b981;
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;

    /* Text Colors */
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --text-subtle: #52525b;

    /* Border Colors */
    --border-primary: #27272a;
    --border-secondary: #3f3f46;
    --border-glow: rgba(59, 130, 246, 0.3);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(59, 130, 246, 0.15);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* Reset & Base Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============================================
   Header Styles
   ============================================ */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-xl);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    height: 56px;
    overflow: visible;
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    overflow: visible;
}

.brand-logo {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-sm);
    font-size: 20px;
}

.logo-icon {
    color: white;
    font-weight: 700;
}

.brand-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.brand-logo-img {
    height: 90px;
    width: 90px;
    object-fit: contain;
    border-radius: 50%;
    position: relative;
    z-index: 101;
    margin-top: 0;
    margin-bottom: -35px;
}

.header-nav {
    display: flex;
    gap: var(--space-sm);
}

.nav-link {
    padding: var(--space-sm) var(--space-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.nav-link.active {
    color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    flex: 1;
    padding: var(--space-xl);
    padding-top: calc(var(--space-xl) + 20px);
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* ============================================
   Tools Section
   ============================================ */
.tools-section {
    margin-bottom: var(--space-2xl);
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-lg);
}

/* Tool Card */
.tool-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    cursor: pointer;
    transition: all var(--transition-base);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 240px;
}

.tool-card:hover {
    border-color: var(--border-secondary);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.tool-card:hover .card-glow {
    opacity: 1;
}

.card-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
            transparent,
            var(--accent-primary),
            var(--accent-cyan),
            var(--accent-primary),
            transparent);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.card-content {
    flex: 1;
}

.card-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(99, 102, 241, 0.1));
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.card-icon svg {
    width: 24px;
    height: 24px;
    color: var(--accent-primary);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    letter-spacing: -0.01em;
}

.card-description {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: var(--space-lg);
}

.card-stats {
    display: flex;
    gap: var(--space-lg);
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-action {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--accent-primary);
    font-size: 13px;
    font-weight: 600;
    margin-top: var(--space-md);
    opacity: 0;
    transform: translateX(-10px);
    transition: all var(--transition-base);
}

.card-action svg {
    width: 16px;
    height: 16px;
}

.tool-card:hover .card-action {
    opacity: 1;
    transform: translateX(0);
}

/* Coming Soon State */
.tool-card.coming-soon {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.tool-card.coming-soon:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--border-primary);
}

.tool-card.coming-soon .card-glow {
    display: none;
}

.tool-card.coming-soon .card-action {
    display: none;
}

.tool-card.coming-soon .card-stats {
    display: none;
}

.coming-soon-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    background: linear-gradient(135deg, var(--accent-amber), #d97706);
    color: white;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 6px 12px;
    border-radius: 20px;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

/* ============================================
   Analysis Section
   ============================================ */
.analysis-section {
    margin-top: var(--space-2xl);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.section-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.section-controls {
    display: flex;
    gap: var(--space-md);
}

.time-select {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.time-select:hover {
    border-color: var(--border-secondary);
}

.time-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.no-data {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 14px;
}

.analysis-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    margin-bottom: var(--space-lg);
    transition: opacity 0.3s ease;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.panel-indicator {
    width: 8px;
    height: 8px;
    background: var(--accent-green);
    border-radius: 50%;
}

.panel-indicator.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.panel-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.metric-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
}

.metric-value {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-bottom: var(--space-xs);
}

.metric-value .value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    line-height: 1;
}

.metric-value .unit {
    font-size: 16px;
    color: var(--text-muted);
}

.metric-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.metric-trend {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 12px;
}

.metric-trend svg {
    width: 14px;
    height: 14px;
}

.metric-trend.positive {
    color: var(--accent-green);
}

.metric-trend.negative {
    color: var(--accent-red);
}

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

/* Chart Container */
.chart-container {
    height: 260px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    position: relative;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Resolver Table */
.resolver-table {
    overflow: hidden;
}

.table-header,
.table-row {
    display: grid;
    grid-template-columns: 50px 140px 1fr 100px 100px 100px;
    gap: var(--space-md);
    padding: var(--space-md);
    align-items: center;
}

.table-header {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-sm);
}

.table-row {
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.table-row:hover {
    background: var(--bg-secondary);
}

.col-rank {
    font-weight: 600;
    color: var(--text-muted);
}

.col-ip {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--accent-primary);
}

.col-org {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-latency {
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-cyan);
}

.col-reliability {
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 600;
}

.col-reliability.high {
    color: var(--accent-green);
}

.col-reliability.medium {
    color: var(--accent-amber);
}

.col-reliability.low {
    color: var(--accent-red);
}

.col-samples {
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================
   Footer
   ============================================ */
.footer {
    padding: var(--space-md) var(--space-xl);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-primary);
}

.footer-content {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-size: 12px;
    color: var(--text-muted);
}

.footer-divider {
    color: var(--border-secondary);
}

.footer-status {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.status-dot {
    width: 6px;
    height: 6px;
    background: var(--accent-green);
    border-radius: 50%;
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

.animate-slide-up {
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.animate-scale-in {
    animation: scaleIn 0.2s ease-out;
}

/* Staggered animation for cards */
.tool-card:nth-child(1) {
    animation-delay: 0.05s;
}

.tool-card:nth-child(2) {
    animation-delay: 0.1s;
}

.tool-card:nth-child(3) {
    animation-delay: 0.15s;
}

.tool-card:nth-child(4) {
    animation-delay: 0.2s;
}

.tool-card:nth-child(5) {
    animation-delay: 0.25s;
}

.tool-card:nth-child(6) {
    animation-delay: 0.3s;
}

.tool-card {
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 1200px) {
    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: var(--space-md);
        padding: var(--space-md);
    }

    .main-content {
        padding: var(--space-md);
    }

    .tools-grid {
        grid-template-columns: 1fr;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .table-header,
    .table-row {
        grid-template-columns: 40px 100px 1fr 80px;
    }

    .col-reliability,
    .col-samples {
        display: none;
    }
}