:root {
    --bg-dark: #0a0e17;
    --card-bg: rgba(16, 23, 40, 0.45);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    /* Emerald Accents */
    --accent-primary: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.4);
    --accent-secondary: #059669;

    /* Error / Warning */
    --error: #ef4444;
    --warning: #f59e0b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    overflow-y: auto;
    /* Prevent scrolling from animated bg */
    position: relative;
}

/* --- Animated Background Shapes --- */
.bg-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    opacity: 0.5;
    animation: float 20s infinite ease-in-out alternate;
}

.shape1 {
    width: 600px;
    height: 600px;
    background: rgba(16, 185, 129, 0.15);
    /* Emerald */
    top: -200px;
    left: -200px;
}

.shape2 {
    width: 500px;
    height: 500px;
    background: rgba(59, 130, 246, 0.1);
    /* Blueish */
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
}

.shape3 {
    width: 400px;
    height: 400px;
    background: rgba(16, 185, 129, 0.1);
    top: 40%;
    left: 40%;
    animation-delay: -10s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(50px, -50px) scale(1.1);
    }
}

/* --- Main Layout --- */
.container {
    width: 100%;
    max-width: 540px;
    padding: 1.5rem;
    z-index: 10;
}

.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.glass-card:hover {
    transform: translateY(-5px);
}

/* --- Header --- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
}

h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 0.25rem;
    background: linear-gradient(to right, #fff, #a7f3d0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 300;
}

.connection-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--warning);
    /* Default connecting */
}

/* Status variants */
.status-connected .status-dot {
    background-color: var(--accent-primary);
    box-shadow: 0 0 12px var(--accent-glow);
}

.status-connected {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--accent-primary);
}

.status-error .status-dot {
    background-color: var(--error);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}

.status-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--error);
}

/* --- Power Display --- */
.power-showcase {
    display: flex;
    justify-content: center;
    margin: 2.5rem 0;
}

.ring-container {
    position: relative;
    width: 220px;
    height: 220px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.glow-ring {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    border: 2px dashed rgba(16, 185, 129, 0.2);
    animation: rotate 20s linear infinite;
}

.glow-ring::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--accent-primary);
    border-right-color: rgba(16, 185, 129, 0.5);
    animation: rotate 10s cubic-bezier(0.4, 0, 0.2, 1) infinite reverse;
}

@keyframes rotate {
    100% {
        transform: rotate(360deg);
    }
}

.power-content {
    display: flex;
    align-items: baseline;
    z-index: 2;
}

.power-value {
    font-size: 5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 30px var(--accent-glow);
    color: #fff;
}

.power-unit {
    font-size: 1.75rem;
    font-weight: 300;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

/* --- Info Grid --- */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.info-item {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.info-label {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
}

.info-value {
    font-size: 1.1rem;
    font-weight: 400;
    color: #fff;
}

/* --- Chart --- */
.chart-wrapper {
    position: relative;
    height: 180px;
    width: 100%;
    margin-top: 1rem;
}

/* --- Logs --- */
.toggle-logs-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    margin-top: 1.5rem;
    display: inline-block;
    transition: color 0.2s;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.toggle-logs-btn:hover {
    color: #fff;
}

.logs-container {
    display: none;
    margin-top: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 1rem;
    height: 150px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.logs-container.visible {
    display: block;
    animation: fade-in 0.3s ease;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#log-output p {
    font-family: 'Consolas', monospace;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
}

#log-output p.error {
    color: var(--error);
}

#log-output p.warn {
    color: var(--warning);
}

#log-output p.info {
    color: #60a5fa;
}

/* Scrollbar styling for logs */
.logs-container::-webkit-scrollbar {
    width: 6px;
}

.logs-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.logs-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}