:root {
    /* Light Theme */
    --bg-color: #f0f4f8;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(255, 255, 255, 0.8);
    --shadow-color: rgba(0, 0, 0, 0.05);
    
    --battery-bg: rgba(200, 200, 200, 0.3);
    --battery-border: #cbd5e1;
    --bolt-color: rgba(255, 255, 255, 0.9);
    
    --color-high: #10b981; /* Emerald */
    --color-medium: #f59e0b; /* Amber */
    --color-low: #ef4444; /* Red */
}

[data-theme="dark"] {
    /* Dark Theme */
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.4);
    
    --battery-bg: rgba(0, 0, 0, 0.4);
    --battery-border: #334155;
    --bolt-color: rgba(255, 255, 255, 0.9);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    transition: background-color 0.4s ease, color 0.4s ease;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    background-image: radial-gradient(circle at 50% -20%, rgba(56, 189, 248, 0.1), transparent 50%),
                      radial-gradient(circle at 100% 100%, rgba(16, 185, 129, 0.05), transparent 50%);
}

.app-container {
    width: 100%;
    max-width: 500px;
    min-height: 100vh;
    padding: 4vh 1.5rem 6vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2.5rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 2.2rem;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.icon-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-size: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
    box-shadow: 0 4px 10px var(--shadow-color);
}

.icon-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 15px var(--shadow-color);
}

.icon-btn:active {
    transform: translateY(0) scale(0.95);
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px var(--shadow-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px var(--shadow-color);
}

/* Battery UI */
.battery-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 0;
}

.battery-wrapper {
    position: relative;
    padding-top: 12px; 
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
    100% { transform: translateY(0px); }
}

.battery {
    width: 140px;
    height: 280px;
    border: 4px solid var(--battery-border);
    border-radius: 20px;
    position: relative;
    background: var(--battery-bg);
    padding: 6px;
    display: flex;
    align-items: flex-end;
    box-shadow: 0 15px 35px var(--shadow-color), inset 0 4px 10px rgba(0,0,0,0.05);
    backdrop-filter: blur(5px);
    transition: border-color 0.4s ease;
}

.battery::before {
    content: '';
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 10px;
    background: var(--battery-border);
    border-radius: 6px 6px 0 0;
    transition: background 0.4s ease;
}

.battery-level {
    width: 100%;
    height: 100%; 
    border-radius: 12px;
    background-color: var(--color-high); 
    transition: height 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.5s ease, box-shadow 0.5s ease;
    box-shadow: 0 0 25px var(--color-high);
    position: relative;
    overflow: hidden;
}

/* Charging Stripes Animation */
.battery-level.charging {
    background-image: linear-gradient(
        -45deg,
        rgba(255, 255, 255, 0.2) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0.2) 75%,
        transparent 75%,
        transparent
    );
    background-size: 40px 40px;
    animation: chargingStripes 1.5s linear infinite;
}

@keyframes chargingStripes {
    0% { background-position: 0 0; }
    100% { background-position: 0 40px; }
}

.battery-level::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.4) 50%, rgba(255,255,255,0) 100%);
    animation: shine 3s infinite;
}

@keyframes shine {
    to { left: 200%; }
}

.battery-bolt {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    color: var(--bolt-color);
    z-index: 10;
    opacity: 0.9;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.2));
    transition: transform 0.3s;
}

.battery-bolt:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

.status-text {
    text-align: center;
}

.status-text h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 4.5rem;
    font-weight: 800;
    margin-bottom: 0.2rem;
    transition: color 0.5s ease;
    letter-spacing: -1px;
}

.status-text p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 500;
    transition: color 0.4s ease;
}

/* Controls */
.controls-section h3, .chart-section h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.styled-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 14px;
    background: var(--battery-bg);
    border-radius: 7px;
    outline: none;
    margin-bottom: 2rem;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
    transition: background 0.4s;
}

.styled-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    border: 3px solid var(--text-primary);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.4s;
}

.styled-slider::-webkit-slider-thumb:active {
    transform: scale(1.2);
}

.styled-slider::-moz-range-thumb {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    border: 3px solid var(--text-primary);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.4s;
}

.styled-slider::-moz-range-thumb:active {
    transform: scale(1.2);
}

.primary-btn {
    width: 100%;
    padding: 1.1rem;
    border: none;
    border-radius: 14px;
    background: var(--text-primary);
    color: var(--bg-color);
    font-family: 'Inter', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.4s, color 0.4s;
    box-shadow: 0 8px 20px var(--shadow-color);
    position: relative;
    overflow: hidden;
}

.primary-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.5s ease;
}

.primary-btn:active::after {
    transform: translate(-50%, -50%) scale(1);
    transition: transform 0s;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px var(--shadow-color);
}

.primary-btn:active {
    transform: translateY(1px);
    box-shadow: 0 5px 10px var(--shadow-color);
}

/* Chart */
.chart-container {
    position: relative;
    height: 220px;
    width: 100%;
}

.text-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    margin-top: 1.5rem;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s;
    width: 100%;
    text-align: center;
}

.text-btn:hover {
    color: var(--color-low);
}

@media (max-width: 480px) {
    .app-container {
        padding: 5vh 1.2rem 8vh;
    }
    .battery {
        width: 120px;
        height: 240px;
    }
    .battery-bolt {
        font-size: 3.5rem;
    }
    .status-text h2 {
        font-size: 3.8rem;
    }
    h1 {
        font-size: 1.8rem;
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    width: 90%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.styled-input {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--battery-border);
    border-radius: 12px;
    background: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

.styled-input:focus {
    border-color: var(--color-high);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    align-items: center;
}

.small-btn {
    width: auto;
    padding: 0.8rem 1.5rem;
}

/* Pill Button */
.pill-btn {
    margin-top: 1.5rem;
    padding: 0.8rem 1.8rem;
    border-radius: 50px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s, background 0.3s;
    box-shadow: 0 4px 15px var(--shadow-color);
}

.pill-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px var(--shadow-color);
    background: var(--text-primary);
    color: var(--bg-color);
    border-color: transparent;
}

.pill-btn:active {
    transform: translateY(0);
}

.chart-modal-content {
    max-width: 600px;
    width: 95%;
    padding: 2rem;
}

/* Premium Theme Switch */
.theme-switch {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 76px;
    height: 38px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 40px;
    padding: 0 4px;
    cursor: pointer;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.05), 0 4px 12px var(--shadow-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.theme-switch:hover {
    transform: translateY(-2px);
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.05), 0 6px 15px var(--shadow-color);
}

.theme-switch:active {
    transform: translateY(0);
}

.theme-switch-puck {
    position: absolute;
    width: 30px;
    height: 30px;
    background: var(--text-primary);
    border-radius: 50%;
    top: 3px;
    left: 4px;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.4s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

[data-theme="dark"] .theme-switch-puck {
    transform: translateX(36px);
}

.theme-switch i {
    z-index: 1;
    font-size: 1.1rem;
    width: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.4s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-icon-sun {
    color: var(--bg-color); 
}
.theme-icon-moon {
    color: var(--text-secondary);
}

[data-theme="dark"] .theme-icon-sun {
    color: var(--text-secondary);
    transform: rotate(90deg);
}
[data-theme="dark"] .theme-icon-moon {
    color: var(--bg-color);
    transform: rotate(-360deg);
}

[data-theme="light"] .theme-icon-sun {
    transform: rotate(0deg);
}
[data-theme="light"] .theme-icon-moon {
    transform: rotate(0deg);
}
