:root {
    --bg-color: #0f172a; /* Slate 900 */
    --panel-bg: rgba(30, 41, 59, 0.7); /* Slate 800 with opacity */
    --panel-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc; /* Slate 50 */
    --text-secondary: #94a3b8; /* Slate 400 */
    --accent: #3b82f6; /* Blue 500 */
    --accent-hover: #2563eb; /* Blue 600 */
    --accent-glow: rgba(59, 130, 246, 0.5);
    --success: #10b981;
    --error: #ef4444;
    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

:root[data-theme="light"] {
    --bg-color: #f8fafc; /* Slate 50 */
    --panel-bg: rgba(255, 255, 255, 0.7); /* White with opacity */
    --panel-border: rgba(0, 0, 0, 0.1);
    --text-primary: #1e293b; /* Slate 800 */
    --text-secondary: #475569; /* Slate 600 */
    --accent: #3b82f6; 
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.3);
}

:root[data-theme="light"] .terminal-window {
    background: #1e293b; /* Keep terminal dark even in light mode */
    border: 1px solid rgba(0, 0, 0, 0.1);
}

:root[data-theme="light"] input, :root[data-theme="light"] select {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
}

:root[data-theme="light"] select option {
    background-color: #ffffff;
}

:root[data-theme="light"] .ip-badge {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

:root[data-theme="light"] .ip-label {
    border-right: 1px solid rgba(0, 0, 0, 0.1);
}

:root[data-theme="light"] .speedtest-ui {
    background: rgba(255, 255, 255, 0.4);
}

:root[data-theme="light"] .metric {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

:root[data-theme="light"] .gauge-bg {
    stroke: rgba(0,0,0,0.1);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Background Animated Blobs */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: -1;
    pointer-events: none;
}

.theme-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.6;
    animation: float 20s infinite alternate ease-in-out;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(59,130,246,0.4) 0%, rgba(15,23,42,0) 70%);
    animation-delay: 0s;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, rgba(139,92,246,0.3) 0%, rgba(15,23,42,0) 70%);
    animation-delay: -5s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(5%, 5%) scale(1.1); }
}

.app-container {
    width: 100%;
    max-width: 1000px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    z-index: 1;
}

header {
    text-align: center;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.header-text {
    text-align: left;
}

@media (max-width: 768px) {
    .header-text {
        text-align: center;
    }
}

.header-logo {
    max-height: 250px;
    margin-bottom: 0;
    object-fit: contain;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #60a5fa, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header .subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 0;
}

.client-ip-info {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.ip-badge {
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--panel-border);
    border-radius: 2rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
    backdrop-filter: blur(8px);
}

.ip-label {
    font-weight: 600;
    margin-right: 0.5rem;
    padding-right: 0.5rem;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.ipv4-badge .ip-label { color: #60a5fa; }
.ipv6-badge .ip-label { color: #c084fc; }

.ip-value {
    font-family: var(--font-mono);
    color: var(--text-primary);
}

main {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1.5rem;
    align-items: stretch;
}

@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
    }
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel:hover {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 20px 0 var(--accent-glow);
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input, select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

select option {
    background-color: var(--bg-color);
}

.primary-btn {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.1s, filter 0.2s;
    box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.4);
}

.primary-btn:hover {
    filter: brightness(1.1);
}

.primary-btn:active {
    transform: scale(0.98);
}

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

.loader {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.output-panel {
    display: flex;
    flex-direction: column;
}

.output-header {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 0.75rem;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    margin-right: 0.75rem;
    box-shadow: 0 0 8px currentColor;
}

.status-indicator.active { background-color: var(--success); }
.status-indicator.error { background-color: var(--error); }

#output-title {
    font-size: 1.1rem;
    font-weight: 600;
    flex-grow: 1;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: color 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.terminal-window {
    flex-grow: 1;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 0.5rem;
    padding: 1rem;
    overflow-y: auto;
    max-height: 500px;
    min-height: 300px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
    border: 1px solid rgba(0,0,0,0.5);
}

/* Custom Scrollbar for Terminal */
.terminal-window::-webkit-scrollbar {
    width: 8px;
}
.terminal-window::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
.terminal-window::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}
.terminal-window::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

#output-content {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.5;
    color: #a7f3d0; /* Emerald 200 */
    white-space: pre-wrap;
    word-break: break-all;
}

#output-content .err {
    color: #fca5a5; /* Red 300 */
}

/* Speedtest Custom UI */
.speedtest-ui {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.5rem;
    padding: 2rem;
}

.gauge-container {
    text-align: center;
    position: relative;
}

.gauge {
    position: relative;
    width: 200px;
    height: 120px;
    margin: 0 auto;
}

.gauge-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.gauge-bg {
    fill: none;
    stroke: rgba(255,255,255,0.1);
    stroke-width: 8;
    stroke-linecap: round;
}

.gauge-fill {
    fill: none;
    stroke: url(#gradient);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s ease-out;
}

.gauge-value {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 2.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.gauge-unit {
    position: absolute;
    bottom: 0px;
    left: 0;
    width: 100%;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.speedtest-metrics {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
}

.metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255,255,255,0.05);
    padding: 1rem;
    border-radius: 0.5rem;
    min-width: 120px;
    border: 1px solid rgba(255,255,255,0.1);
}

.metric-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: 1.25rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

#dl-value { color: #60a5fa; }
#ul-value { color: #c084fc; }

footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 1rem;
}
