/* 
 * AMERUNET Speedtest Design System
 * Aesthetic: Cyber-Futurism, Glassmorphism, Sleek Dark Mode, Glowing Accents
 */

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

:root {
    --bg-dark-1: #060914;
    --bg-dark-2: #0d122b;
    --bg-dark-3: #131b3d;
    --card-bg: rgba(13, 18, 43, 0.65);
    --card-border: rgba(0, 242, 254, 0.08);
    --card-border-focus: rgba(0, 242, 254, 0.25);
    --text-main: #f1f5f9;
    --text-muted: #64748b;
    
    --color-ping: #06b6d4;      /* Cyan */
    --color-ping-glow: rgba(6, 182, 212, 0.25);
    
    --color-down: #10b981;      /* Emerald */
    --color-down-glow: rgba(16, 185, 129, 0.25);
    
    --color-up: #d946ef;        /* Magenta */
    --color-up-glow: rgba(217, 70, 239, 0.25);
    
    --color-accent: #3b82f6;    /* Blue */
    --color-gray: #334155;
    
    --gauge-color-1: #00f2fe;
    --gauge-color-2: #4facfe;
    --gauge-glow: rgba(0, 242, 254, 0.35);

    --font-ui: 'Outfit', sans-serif;
    --font-mono: 'Share Tech Mono', monospace;
    
    --transition-speed: 0.3s;
}

/* Reset & Basic Setup */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-dark-1);
    background-image: radial-gradient(circle at 50% 50%, var(--bg-dark-2) 0%, var(--bg-dark-1) 100%);
    color: var(--text-main);
    font-family: var(--font-ui);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
}

/* Cyber grid scan background */
.grid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: 50px 50px;
    background-image: 
        linear-gradient(to right, rgba(255, 255, 255, 0.015) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
    z-index: -2;
    pointer-events: none;
}

.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, transparent 40%, rgba(3, 4, 10, 0.8) 100%);
    z-index: -1;
    pointer-events: none;
}

/* Container */
.container {
    width: 100%;
    max-width: 1280px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Header */
header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 20px;
    margin-top: 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.logo h1 {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: 4px;
    color: var(--text-main);
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

.logo h1 span {
    color: var(--color-ping);
    text-shadow: 0 0 10px var(--color-ping-glow);
}

.pulse-dot {
    width: 12px;
    height: 12px;
    background-color: var(--color-ping);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--color-ping);
    animation: pulse 1.8s infinite ease-in-out;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 5px;
    font-weight: 500;
    margin-bottom: 12px;
}

.status-badge {
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: 20px;
    padding: 4px 16px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 2px;
    color: var(--color-ping);
    text-shadow: 0 0 5px var(--color-ping-glow);
    animation: text-pulse 2s infinite alternate;
}

/* Glassmorphism Cards */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    transition: all var(--transition-speed) cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(0, 242, 254, 0.3), transparent);
    transform: translateX(-100%);
}

.glass-card:hover::before {
    transform: translateX(100%);
    transition: transform 1.2s ease;
}

.glass-card:hover {
    border-color: var(--card-border-focus);
    box-shadow: 0 12px 40px 0 rgba(0, 242, 254, 0.05);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--text-muted);
}

.icon-small {
    width: 16px;
    height: 16px;
    fill: var(--text-muted);
}

.scanline-indicator {
    width: 6px;
    height: 6px;
    background-color: var(--color-ping);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--color-ping);
}

/* Dashboard Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 440px 1fr;
    gap: 24px;
}

/* Left Panel: Speedometer */
.gauge-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
}

.gauge-container {
    position: relative;
    width: 300px;
    height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
}

.gauge {
    width: 100%;
    height: 100%;
    transform: rotate(135deg); /* Align 3/4 gauge properly */
    overflow: visible;
}

.gauge-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.03);
    stroke-width: 8;
}

.gauge-ticks {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 4;
    stroke-dasharray: 2 10;
}

.gauge-progress {
    fill: none;
    stroke: url(#gauge-grad);
    stroke-width: 9;
    stroke-linecap: round;
    stroke-dasharray: 377 502.65; /* 3/4 length of radius 80 circle */
    stroke-dashoffset: 377; /* Fully empty */
    transition: stroke-dashoffset 0.15s ease-out;
    filter: drop-shadow(0 0 10px var(--gauge-glow));
}

/* Dynamic colors of gauge */
.gauge-progress.pinging {
    --gauge-color-1: #00f2fe;
    --gauge-color-2: #4facfe;
    --gauge-glow: rgba(0, 242, 254, 0.45);
}

.gauge-progress.downloading {
    --gauge-color-1: #10b981;
    --gauge-color-2: #34d399;
    --gauge-glow: rgba(16, 185, 129, 0.45);
}

.gauge-progress.uploading {
    --gauge-color-1: #d946ef;
    --gauge-color-2: #f472b6;
    --gauge-glow: rgba(217, 70, 239, 0.45);
}

.gauge-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

/* Readout panel inside gauge */
#readout-container {
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.readout-hidden {
    opacity: 0;
    transform: scale(0.6);
    pointer-events: none;
    position: absolute;
}

.readout-visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.speed-value {
    font-family: var(--font-mono);
    font-size: 3.5rem;
    font-weight: 500;
    line-height: 1;
    color: var(--text-main);
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.15);
    margin-bottom: 4px;
}

.speed-unit {
    font-size: 0.9rem;
    letter-spacing: 4px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.test-phase {
    margin-top: 12px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 2px;
    padding: 3px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

/* Active phases color states */
.test-phase.phase-ping {
    color: var(--color-ping);
    border-color: rgba(6, 182, 212, 0.2);
    background: rgba(6, 182, 212, 0.05);
    text-shadow: 0 0 4px var(--color-ping-glow);
}

.test-phase.phase-down {
    color: var(--color-down);
    border-color: rgba(16, 185, 129, 0.2);
    background: rgba(16, 185, 129, 0.05);
    text-shadow: 0 0 4px var(--color-down-glow);
}

.test-phase.phase-up {
    color: var(--color-up);
    border-color: rgba(217, 70, 239, 0.2);
    background: rgba(217, 70, 239, 0.05);
    text-shadow: 0 0 4px var(--color-up-glow);
}

/* Action Start Button inside Gauge */
.start-trigger {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--bg-dark-3) 0%, var(--bg-dark-2) 100%);
    border: 2px solid var(--color-ping);
    box-shadow: 0 0 25px rgba(0, 242, 254, 0.2), inset 0 0 15px rgba(0, 242, 254, 0.1);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 15;
}

.start-trigger:hover {
    transform: scale(1.06);
    border-color: #ffffff;
    box-shadow: 0 0 35px rgba(0, 242, 254, 0.4), inset 0 0 20px rgba(0, 242, 254, 0.2);
}

.start-trigger:active {
    transform: scale(0.96);
}

.start-trigger.trigger-hidden {
    opacity: 0;
    transform: scale(0.5);
    pointer-events: none;
    position: absolute;
}

.btn-ripple {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--color-ping);
    opacity: 0.5;
    animation: ripple 2.5s infinite linear;
    pointer-events: none;
}

.btn-text {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: bold;
    letter-spacing: 2px;
    margin-bottom: 6px;
    color: var(--text-main);
}

.btn-icon {
    width: 24px;
    height: 24px;
    fill: var(--color-ping);
    filter: drop-shadow(0 0 5px var(--color-ping));
}

/* Gauge Footer Stats */
.gauge-footer-stats {
    display: flex;
    justify-content: space-around;
    width: 100%;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    padding-top: 16px;
    margin-top: 10px;
}

.footer-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-lbl {
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 2px;
    margin-bottom: 4px;
}

.stat-val {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-main);
}

/* Right Panel: Metrics + Chart */
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Metrics Dashboard */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: rgba(13, 18, 43, 0.45);
    position: relative;
}

.metric-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.metric-icon svg {
    width: 24px;
    height: 24px;
    fill: var(--text-muted);
    transition: fill 0.3s ease;
}

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

.metric-data .label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.metric-data .value {
    font-family: var(--font-mono);
    font-size: 1.6rem;
    font-weight: 500;
    color: var(--text-main);
    line-height: 1.1;
    display: flex;
    align-items: baseline;
}

.metric-data .value .unit {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 4px;
}

.metric-data .sub-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Bottom Glow bar on metric cards */
.metric-indicator-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--color-gray);
    transition: all 0.4s ease;
}

/* Card States active / complete */
.card-ping.active .metric-icon {
    border-color: var(--color-ping);
    background: rgba(6, 182, 212, 0.1);
}
.card-ping.active svg { fill: var(--color-ping); }
.card-ping.active .metric-indicator-bar {
    background: var(--color-ping);
    box-shadow: 0 0 10px var(--color-ping);
}

.card-down.active .metric-icon {
    border-color: var(--color-down);
    background: rgba(16, 185, 129, 0.1);
}
.card-down.active svg { fill: var(--color-down); }
.card-down.active .metric-indicator-bar {
    background: var(--color-down);
    box-shadow: 0 0 10px var(--color-down);
}

.card-up.active .metric-icon {
    border-color: var(--color-up);
    background: rgba(217, 70, 239, 0.1);
}
.card-up.active svg { fill: var(--color-up); }
.card-up.active .metric-indicator-bar {
    background: var(--color-up);
    box-shadow: 0 0 10px var(--color-up);
}

/* Chart Container */
.chart-card {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 8px 12px 16px;
}

.chart-legend {
    display: flex;
    gap: 16px;
}

.legend-item {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.legend-down .legend-dot { background: var(--color-down); box-shadow: 0 0 6px var(--color-down-glow); }
.legend-up .legend-dot { background: var(--color-up); box-shadow: 0 0 6px var(--color-up-glow); }

.chart-container {
    position: relative;
    width: 100%;
    height: 180px;
    margin-top: 12px;
}

#speedChart {
    width: 100%;
    height: 100%;
    display: block;
}

/* Bottom Information Grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.info-card {
    padding: 20px;
}

.info-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.info-header svg {
    width: 18px;
    height: 18px;
    fill: var(--color-ping);
}

.info-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}

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

.info-row .val {
    font-family: var(--font-mono);
    color: var(--text-main);
    text-align: right;
}

.text-green {
    color: var(--color-down) !important;
    text-shadow: 0 0 5px var(--color-down-glow);
}

/* Actions Card specific layout */
.actions-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.actions-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: calc(100% - 40px);
    justify-content: center;
}

.action-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--color-ping) 0%, var(--color-accent) 100%);
    border: none;
    border-radius: 12px;
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: bold;
    color: #030712;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 242, 254, 0.15);
    letter-spacing: 1px;
}

.action-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 242, 254, 0.3);
}

.action-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.action-btn:disabled {
    background: var(--color-gray);
    color: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.5;
}

.action-btn.secondary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    box-shadow: none;
}

.action-btn.secondary:hover {
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.02);
}

/* Console Panel styling */
.console-panel {
    border-color: rgba(255, 255, 255, 0.05);
    margin-top: 10px;
}

.console-panel.hidden {
    display: none;
}

.console-output {
    height: 140px;
    overflow-y: auto;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.3);
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.75rem;
    line-height: 1.6;
    border-radius: 0 0 24px 24px;
}

/* Custom Scrollbar for console and modal */
.console-output::-webkit-scrollbar, .modal-body::-webkit-scrollbar {
    width: 6px;
}
.console-output::-webkit-scrollbar-track, .modal-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
.console-output::-webkit-scrollbar-thumb, .modal-body::-webkit-scrollbar-thumb {
    background: var(--color-gray);
    border-radius: 3px;
}

.log-line {
    margin-bottom: 4px;
    white-space: pre-wrap;
}

.log-line.system { color: #3b82f6; }
.log-line.ping { color: var(--color-ping); }
.log-line.down { color: var(--color-down); }
.log-line.up { color: var(--color-up); }
.log-line.error { color: #ef4444; }

.close-console {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}
.close-console:hover {
    color: var(--text-main);
}

/* Shareable Image Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity var(--transition-speed) ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(3, 7, 18, 0.85);
    backdrop-filter: blur(8px);
}

.modal-content {
    width: 90%;
    max-width: 540px;
    z-index: 101;
    transform: scale(0.9);
    transition: transform var(--transition-speed) cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-color: rgba(255, 255, 255, 0.1);
}

.modal.visible .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--color-ping);
    text-shadow: 0 0 5px var(--color-ping-glow);
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 24px;
    text-align: center;
}

.modal-body p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.image-preview-container {
    background: rgba(0, 0, 0, 0.3);
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    display: inline-block;
    max-width: 100%;
}

.image-preview-container img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.modal-footer {
    padding: 16px 24px 24px;
    display: flex;
    justify-content: flex-end;
}

/* Footer Section */
footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 10px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    margin-top: 10px;
}

/* Keyframe Animations */
@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 8px rgba(6, 182, 212, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(6, 182, 212, 0);
    }
}

@keyframes text-pulse {
    0% {
        opacity: 0.8;
        box-shadow: 0 0 4px rgba(6, 182, 212, 0.1);
    }
    100% {
        opacity: 1;
        box-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
    }
}

@keyframes ripple {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .gauge-panel {
        padding: 32px;
    }
    
    .gauge-container {
        width: 320px;
        height: 320px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
        gap: 16px;
    }
    
    .logo h1 {
        font-size: 1.8rem;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .gauge-container {
        width: 260px;
        height: 260px;
    }
    
    .speed-value {
        font-size: 2.8rem;
    }
    
    footer {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
}
