/*
 * app.css
 * Toolstrem Ping Test styling.
 * Supports fluid layouts, dark/light mode switches, and premium aesthetics.
 */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
    /* Color tokens - Dark Mode by default */
    --font-primary: 'Outfit', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --bg-base: #0f111a;
    --bg-surface: rgba(22, 26, 41, 0.65);
    --bg-surface-solid: #161a29;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-accent: rgba(0, 102, 255, 0.25);
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dimmed: #6b7280;

    --accent-primary: #0066ff;
    --accent-secondary: #00f2fe;
    --accent-glow: rgba(0, 102, 255, 0.4);
    
    --status-success: #10b981;
    --status-success-bg: rgba(16, 185, 129, 0.1);
    --status-warning: #f59e0b;
    --status-warning-bg: rgba(245, 158, 11, 0.1);
    --status-error: #ef4444;
    --status-error-bg: rgba(239, 68, 68, 0.1);

    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --backdrop-blur: blur(12px);
    --transition-speed: 0.25s;
}

[data-theme="light"] {
    --bg-base: #f8fafc;
    --bg-surface: rgba(255, 255, 255, 0.7);
    --bg-surface-solid: #ffffff;
    --border-color: rgba(0, 0, 0, 0.08);
    --border-accent: rgba(0, 102, 255, 0.15);

    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dimmed: #94a3b8;

    --accent-primary: #0284c7;
    --accent-secondary: #0ea5e9;
    --accent-glow: rgba(2, 132, 199, 0.15);

    --card-shadow: 0 8px 32px 0 rgba(148, 163, 184, 0.15);
    --backdrop-blur: blur(12px);
}

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

.ping-body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-primary);
    line-height: 1.6;
    background-image: 
        radial-gradient(at 0% 0%, rgba(0, 102, 255, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(0, 242, 254, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-speed);
}

a:hover {
    color: var(--accent-secondary);
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Glassmorphism Panel */
.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    transition: border-color var(--transition-speed), background var(--transition-speed);
}

.glass-panel:hover {
    border-color: var(--border-accent);
}

/* Header & Navbar */
.ping-header {
    padding: 20px 0;
    margin-bottom: 40px;
    border-bottom: 1px solid var(--border-color);
}

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

.logo {
    font-size: 24px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.nav-links {
    display: flex;
    gap: 20px;
    align-items: center;
    list-style: none;
}

.nav-links a {
    font-weight: 500;
    font-size: 15px;
    color: var(--text-muted);
}

.nav-links a:hover, .nav-links a.active {
    color: var(--text-main);
}

/* Hero Section */
.hero {
    text-align: center;
    margin-bottom: 50px;
    padding-top: 50px;
}

.hero h1 {
    font-size: 44px;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.2;
    margin-bottom: 15px;
    background: linear-gradient(135deg, var(--text-main) 30%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: 17px;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

/* Diagnostic Workspace */
.workspace-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
    margin-bottom: 60px;
}

@media (min-width: 992px) {
    .workspace-grid {
        grid-template-columns: 1.5fr 1fr;
    }
}

.console-panel {
    padding: 30px;
}

.input-group {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
}

.form-control {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px 20px;
    color: var(--text-main);
    font-family: var(--font-primary);
    font-size: 16px;
    outline: none;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.form-control:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 12px var(--accent-glow);
}

.btn {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0 28px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: opacity var(--transition-speed), transform var(--transition-speed);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    background: var(--text-dimmed);
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Options Bar */
.options-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.option-field {
    display: flex;
    align-items: center;
    gap: 8px;
}

.option-field label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.option-field select, .option-field input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 6px 12px;
    color: var(--text-main);
    font-size: 13px;
    outline: none;
}

/* Terminal output wrapper */
.terminal-window {
    background: #060810;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 20px;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.6;
    color: #38bdf8;
    height: 250px;
    overflow-y: auto;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.8);
    margin-bottom: 25px;
}

.terminal-line {
    margin-bottom: 6px;
    word-break: break-all;
}

.terminal-line.error { color: var(--status-error); }
.terminal-line.success { color: var(--status-success); }
.terminal-line.info { color: var(--text-muted); }

/* Statistics Cards Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

@media (min-width: 576px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.stat-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
}

.stat-card h4 {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.stat-card .value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
}

/* Sidebar History/Favorites */
.sidebar-panel {
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

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

.panel-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.list-wrapper {
    max-height: 250px;
    overflow-y: auto;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 10px;
    background: rgba(255,255,255,0.01);
    transition: background var(--transition-speed), border-color var(--transition-speed);
    cursor: pointer;
}

.list-item:hover {
    background: rgba(0,102,255,0.05);
    border-color: var(--border-accent);
}

.list-item .details {
    display: flex;
    flex-direction: column;
}

.list-item .details .host {
    font-weight: 600;
    font-size: 14px;
}

.list-item .details .ip {
    font-size: 11px;
    color: var(--text-dimmed);
}

.list-item .metrics {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.list-item .metrics .avg {
    font-weight: 700;
    font-size: 14px;
    color: var(--accent-secondary);
}

.list-item .metrics .time {
    font-size: 10px;
    color: var(--text-dimmed);
}

/* Export & Action Buttons */
.actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 25px;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 10px 18px;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background var(--transition-speed), border-color var(--transition-speed);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-muted);
}

/* Chart Canvas Wrapper */
.chart-container {
    margin-top: 30px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.chart-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 180px;
}

/* SVG Chart Elements */
.svg-chart {
    width: 100%;
    height: 100%;
}

.chart-line {
    fill: none;
    stroke: var(--accent-primary);
    stroke-width: 3;
    stroke-linecap: round;
    filter: drop-shadow(0 2px 8px var(--accent-glow));
}

.chart-area {
    fill: url(#chart-gradient);
    opacity: 0.15;
}

.chart-grid {
    stroke: var(--border-color);
    stroke-width: 1;
    stroke-dasharray: 4 4;
}

.chart-dot {
    fill: var(--accent-secondary);
    stroke: var(--bg-surface-solid);
    stroke-width: 2;
    cursor: pointer;
    transition: r 0.1s;
}

.chart-dot:hover {
    r: 6;
}

/* Connection Quality / Network Health Gauge */
.health-meter-box {
    display: flex;
    align-items: center;
    gap: 20px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-top: 30px;
}

.quality-badge {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 800;
    color: var(--accent-secondary);
    border: 2px solid var(--accent-primary);
}

.quality-details h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.quality-details p {
    font-size: 13px;
    color: var(--text-muted);
}

/* SEO content details */
.seo-article {
    margin-top: 80px;
    padding-top: 40px;
    border-top: 1px solid var(--border-color);
}

.seo-article h2 {
    font-size: 28px;
    font-weight: 700;
    margin-top: 40px;
    margin-bottom: 20px;
    color: var(--text-main);
}

.seo-article p {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.8;
}

.seo-article ul {
    margin-left: 20px;
    margin-bottom: 25px;
    color: var(--text-muted);
}

.seo-article ul li {
    margin-bottom: 8px;
}

.faq-accordion {
    margin-top: 50px;
}

.faq-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 15px;
    overflow: hidden;
}

.faq-trigger {
    width: 100%;
    text-align: left;
    background: var(--bg-surface);
    border: none;
    padding: 18px 20px;
    font-family: var(--font-primary);
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.faq-content {
    background: rgba(0,0,0,0.1);
    padding: 20px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.7;
}

details.faq-item summary.faq-trigger {
    list-style: none;
    outline: none;
    user-select: none;
}

details.faq-item summary.faq-trigger::-webkit-details-marker {
    display: none;
}

details.faq-item[open] summary.faq-trigger {
    background: rgba(255, 255, 255, 0.02);
}

.faq-icon {
    transition: transform 0.2s ease;
    font-size: 20px;
    font-weight: 400;
    display: inline-block;
}

details.faq-item[open] .faq-icon {
    transform: rotate(45deg);
}

/* Footer Section */
.ping-footer {
    margin-top: 100px;
    padding: 40px 0;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.ping-footer p {
    font-size: 14px;
    color: var(--text-dimmed);
}

/* Utilities */
.text-success { color: var(--status-success) !important; }
.text-warning { color: var(--status-warning) !important; }
.text-danger { color: var(--status-error) !important; }

/* Responsive adjustments */
@media (max-width: 768px) {
    .hero h1 { font-size: 32px; }
    .input-group { flex-direction: column; }
    .btn { padding: 14px 20px; }
}

/* Monospace Code Blocks & Diagrams */
.markdown-code-block {
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px 20px;
    margin: 20px 0;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 13.5px;
    line-height: 1.5;
    color: #a7f3d0;
}
.markdown-code-block code {
    font-family: var(--font-mono);
    white-space: pre;
}

/* Inline Code Code Tags */
.seo-article code {
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 13.5px;
    color: #f43f5e;
}

/* Tables styling */
.markdown-table {
    width: 100%;
    margin: 25px 0;
    border-collapse: collapse;
    font-size: 14.5px;
}
.markdown-table th, .markdown-table td {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    text-align: left;
}
.markdown-table th {
    background: rgba(255, 255, 255, 0.04);
    font-weight: 600;
}

/* Blockquotes & alerts */
.markdown-quote {
    border-left: 4px solid var(--accent-primary);
    background: rgba(255, 255, 255, 0.02);
    padding: 15px 20px;
    margin: 20px 0;
    border-radius: 0 8px 8px 0;
}
.alert {
    padding: 15px 20px;
    margin: 20px 0;
    border-radius: 8px;
    border-left: 4px solid transparent;
}
.alert-note {
    background: rgba(0, 102, 255, 0.05);
    border-left-color: #0066ff;
    color: #93c5fd;
}
.alert-tip {
    background: rgba(16, 185, 129, 0.05);
    border-left-color: #10b981;
    color: #a7f3d0;
}
.alert-important {
    background: rgba(245, 158, 11, 0.05);
    border-left-color: #f59e0b;
    color: #fde68a;
}
.alert-warning, .alert-caution {
    background: rgba(239, 68, 68, 0.05);
    border-left-color: #ef4444;
    color: #fca5a5;
}

/* Custom responsive HTML/CSS diagrams & flowchart components */
.icmp-flow-diagram {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    margin: 25px 0;
    gap: 15px;
}
.diagram-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    min-width: 140px;
    text-align: center;
    color: var(--text-main);
}
.diagram-node i {
    font-size: 28px;
    color: var(--accent-primary);
    filter: drop-shadow(0 0 8px var(--accent-glow));
}
.arrows-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.arrow-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    width: 100%;
}
.arrow-text {
    font-size: 11.5px;
    font-weight: 600;
    text-align: center;
}
.arrow-text.text-request { color: var(--accent-secondary); }
.arrow-text.text-reply { color: var(--status-success); }
.arrow-line {
    height: 2px;
    background: var(--border-color);
    position: relative;
    width: 100%;
}
.arrow-line::after {
    content: '';
    position: absolute;
    top: -4px;
    width: 0;
    height: 0;
    border-style: solid;
}
.arrow-right::after {
    right: 0;
    border-width: 5px 0 5px 8px;
    border-color: transparent transparent transparent var(--accent-secondary);
}
.arrow-left::after {
    left: 0;
    border-width: 5px 8px 5px 0;
    border-color: transparent var(--status-success) transparent transparent;
}

/* ICMP Packet Header Grid */
.packet-header-grid-container {
    overflow-x: auto;
    margin: 25px 0;
}
.packet-header-grid {
    display: grid;
    grid-template-columns: repeat(32, 1fr);
    min-width: 640px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}
.header-cell {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 12px 6px;
    text-align: center;
    font-size: 12px;
    color: var(--text-main);
}
.header-cell.size-8 { grid-column: span 8; }
.header-cell.size-16 { grid-column: span 16; }
.header-cell.size-32 { grid-column: span 32; }
.header-cell strong { color: var(--accent-secondary); }

/* Network Health Cards */
.network-health-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin: 25px 0;
}
.health-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    transition: transform var(--transition-speed), border-color var(--transition-speed);
}
.health-card:hover {
    border-color: var(--border-accent);
    transform: translateY(-4px);
}
.health-card-icon {
    font-size: 32px;
    color: var(--accent-primary);
    margin-bottom: 12px;
    filter: drop-shadow(0 0 8px var(--accent-glow));
}
.health-card h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
}
.health-card p {
    font-size: 14px;
    color: var(--text-muted);
    margin: 4px 0;
}

/* Formula Box */
.formula-box {
    background: rgba(0, 102, 255, 0.03);
    border: 1px solid var(--border-accent);
    border-radius: 8px;
    padding: 16px 20px;
    margin: 20px 0;
    font-family: var(--font-mono);
    font-size: 14.5px;
    color: var(--text-main);
    text-align: center;
}
.formula-box strong {
    color: var(--accent-secondary);
}

/* Troubleshooting Workflow Flowchart */
.troubleshooting-workflow {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 30px 0;
}
.workflow-step {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.workflow-step.warning-step {
    border-color: rgba(245, 158, 11, 0.3);
    background: rgba(245, 158, 11, 0.02);
}
.workflow-step.info-step {
    border-color: rgba(0, 102, 255, 0.3);
    background: rgba(0, 102, 255, 0.02);
}
.step-num {
    position: absolute;
    top: -12px;
    left: 20px;
    width: 24px;
    height: 24px;
    background: var(--accent-primary);
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}
.workflow-step.warning-step .step-num { background: #f59e0b; }
.workflow-step.info-step .step-num { background: #0066ff; }
.workflow-step h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
}
.workflow-step p {
    margin: 0;
    font-size: 14px;
    color: var(--text-muted);
}
.decision-branches {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 5px;
}
.branch {
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    border: 1px solid var(--border-color);
}
.branch-fail {
    background: rgba(239, 68, 68, 0.03);
    border-color: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}
.branch-success {
    background: rgba(16, 185, 129, 0.03);
    border-color: rgba(16, 185, 129, 0.2);
    color: #a7f3d0;
}
.workflow-arrow {
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-dimmed);
    font-size: 18px;
}

/* Sticky Header Overlap Fix & Readability */
.seo-article h2,
.seo-article h3,
.seo-article h4 {
    scroll-margin-top: calc(75px + 24px) !important; /* Prevents overlap with header */
    margin-top: 35px;
    margin-bottom: 15px;
    color: var(--text-main);
}
.seo-article p {
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-muted);
    margin-bottom: 20px;
    max-width: 85ch; /* Comfortable reading line width */
}
[data-theme="light"] .seo-article p {
    color: #334155 !important; /* High contrast Slate-700 in light mode */
}

/* Responsive Overrides */
@media (max-width: 768px) {
    .icmp-flow-diagram {
        flex-direction: column;
        padding: 16px;
    }
    .arrows-column {
        width: 100%;
        margin: 15px 0;
    }
    .arrow-right::after {
        transform: rotate(90deg);
        right: 50%;
        bottom: 0;
        top: auto;
    }
    .arrow-left::after {
        transform: rotate(90deg);
        left: 50%;
        top: 0;
    }
    .decision-branches {
        grid-template-columns: 1fr;
    }
}
