/* ============================================================
   POWER BUDGET CALCULATOR STYLES
   ============================================================ */

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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --purple: #9333ea;
    
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-header: #1e293b;
    --bg-section: #f1f5f9;
    
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ============================================================
   HEADER
   ============================================================ */

.header {
    background: var(--bg-header);
    color: white;
    padding: 24px 0;
    margin-bottom: 32px;
    box-shadow: var(--shadow-lg);
}

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

.logo h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-light);
}

.battery-summary {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(255,255,255,0.1);
    padding: 12px 20px;
    border-radius: 12px;
}

.battery-icon {
    display: flex;
    align-items: center;
}

.battery-body {
    width: 48px;
    height: 24px;
    border: 2px solid white;
    border-radius: 4px;
    padding: 2px;
    position: relative;
    overflow: hidden;
}

.battery-level {
    height: 100%;
    background: var(--success);
    border-radius: 2px;
    transition: width 0.5s ease;
    width: 100%;
}

.battery-tip {
    width: 4px;
    height: 10px;
    background: white;
    border-radius: 0 2px 2px 0;
    margin-left: 2px;
}

.battery-info {
    text-align: center;
}

.battery-days {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--success);
}

.battery-label {
    font-size: 12px;
    color: var(--text-light);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    padding-bottom: 48px;
}

/* ============================================================
   CONFIGURATION PANEL
   ============================================================ */

.config-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.config-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.section-icon {
    font-size: 20px;
}

.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.config-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.config-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.config-item.full-width {
    grid-column: 1 / -1;
}

.config-item label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.config-item select,
.config-item input[type="number"] {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.config-item select:focus,
.config-item input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Component Info */
.component-info {
    background: var(--bg-section);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

.component-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
}

.component-name {
    color: var(--text-secondary);
}

.component-power {
    font-weight: 500;
    color: var(--text-primary);
}

/* Slider Styles */
.slider-container {
    display: flex;
    align-items: center;
    gap: 16px;
}

.slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.4);
    transition: transform 0.2s;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
}

.slider-value {
    min-width: 48px;
    text-align: right;
    font-weight: 600;
    font-size: 14px;
    color: var(--primary);
}

/* Toggle Switch */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 10px 0;
}

.toggle-label input {
    display: none;
}

.toggle-slider {
    width: 44px;
    height: 24px;
    background: var(--border);
    border-radius: 12px;
    position: relative;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    top: 3px;
    left: 3px;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-label input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-label input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.toggle-text {
    font-size: 14px;
    color: var(--text-primary);
}

.pod-toggles {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
}

/* Pod Power List */
.pod-power-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.pod-power-item {
    background: var(--bg-section);
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pod-power-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pod-power-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.pod-power-formula {
    font-size: 11px;
    color: var(--text-secondary);
}

.pod-power-values {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.pod-power-mah {
    font-weight: 600;
    font-size: 14px;
    color: var(--primary);
}

.pod-power-total {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Event Groups */
.event-group {
    background: var(--bg-section);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.event-group:last-child {
    margin-bottom: 0;
}

.event-group-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.event-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.event-controls:last-child {
    margin-bottom: 0;
}

.config-item.half {
    /* Same as config-item but for grid */
}

/* ============================================================
   RESULTS PANEL
   ============================================================ */

.results-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.results-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
}

/* Power Summary */
.power-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.power-item {
    background: var(--bg-section);
    padding: 16px;
    border-radius: 8px;
    text-align: center;
}

.power-item.highlight {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.power-item.highlight.secondary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    opacity: 0.85;
}

.power-item.highlight.secondary .power-label {
    font-size: 11px;
}

.power-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.power-item.highlight .power-label {
    color: rgba(255,255,255,0.8);
}

.power-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.power-item.highlight .power-value {
    font-size: 36px;
    color: white;
}

/* Breakdown Chart */
.breakdown-chart {
    display: flex;
    gap: 24px;
    align-items: flex-end;
}

.chart-bar-container {
    display: flex;
    gap: 8px;
    height: 150px;
    align-items: flex-end;
    flex: 1;
}

.chart-bar {
    flex: 1;
    background: var(--primary);
    border-radius: 6px 6px 0 0;
    position: relative;
    transition: height 0.5s ease;
    min-height: 20px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 8px;
}

.chart-bar#barCore { background: #4CAF50; }
.chart-bar#barModem { background: #2196F3; }
.chart-bar#barPods { background: #FF9800; }
.chart-bar#barEvents { background: #9C27B0; }

.bar-label {
    font-size: 10px;
    font-weight: 600;
    color: white;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-text {
    color: var(--text-secondary);
}

/* Detail List */
.detail-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-section);
    border-radius: 6px;
    font-size: 13px;
}

.detail-name {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

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

.detail-multiplier {
    font-size: 11px;
    color: var(--text-light);
    font-weight: normal;
}

.detail-values {
    text-align: right;
}

.detail-current {
    font-weight: 600;
    color: var(--text-primary);
}

.detail-daily {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Runtime Grid */
.runtime-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.runtime-card {
    background: var(--bg-section);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.runtime-value {
    display: block;
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.runtime-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.runtime-note {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.runtime-note code {
    background: var(--bg-section);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

/* ============================================================
   FOOTER
   ============================================================ */

.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 13px;
}

.footer code {
    background: var(--bg-section);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

.btn-reset {
    margin-top: 12px;
    padding: 8px 16px;
    background: var(--bg-section);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-reset:hover {
    background: var(--border);
    color: var(--text-primary);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .breakdown-chart {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .chart-bar-container {
        width: 100%;
        height: 80px;
    }
    
    .chart-bar {
        writing-mode: horizontal-tb;
    }
    
    .bar-label {
        writing-mode: horizontal-tb;
        transform: none;
    }
    
    .chart-legend {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 16px;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 0 16px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .config-grid {
        grid-template-columns: 1fr;
    }
    
    .power-summary {
        grid-template-columns: 1fr;
    }
    
    .runtime-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.updating {
    animation: pulse 0.5s ease-in-out;
}
