/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #0f1419 0%, #1a2332 50%, #2d3748 100%);
    color: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 30px;
}

.header-left {
    display: flex;
    flex-direction: column;
}

.title {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #00d4ff 0%, #090979 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.version {
    font-size: 14px;
    color: #8892b0;
    margin-top: 4px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

.indicator.connected {
    background: #00ff88;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.6);
}

.indicator.disconnected {
    background: #ff4757;
    box-shadow: 0 0 20px rgba(255, 71, 87, 0.6);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.connect-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.connect-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.connect-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Dashboard Grid */
.dashboard {
    display: grid;
    gap: 30px;
    grid-template-columns: 1fr;
}

/* Data Cards */
.data-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--card-accent);
    opacity: 0.8;
}

.voltage-card {
    --card-accent: linear-gradient(90deg, #00ff88, #00d4ff);
}

.current-card {
    --card-accent: linear-gradient(90deg, #ff6b6b, #feca57);
}

.power-card {
    --card-accent: linear-gradient(90deg, #ff9ff3, #f368e0);
}

.frequency-card {
    --card-accent: linear-gradient(90deg, #54a0ff, #5f27cd);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.2);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-title {
    font-size: 14px;
    color: #8892b0;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-unit {
    font-size: 12px;
    color: #64748b;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
}

.card-value {
    font-size: 36px;
    font-weight: 700;
    color: #ffffff;
    font-variant-numeric: tabular-nums;
}

/* Charts Section */
.charts-section {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.chart-controls {
    display: flex;
    gap: 10px;
}

.chart-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chart-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chart-container {
    position: relative;
}

#realtime-chart {
    width: 100%;
    height: 400px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

/* Info and Controls Section */
.info-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.device-info, .controls {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px;
}

.device-info h3, .controls h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #ffffff;
}

.info-grid {
    display: grid;
    gap: 16px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    font-size: 14px;
    color: #8892b0;
}

.info-value {
    font-size: 14px;
    color: #ffffff;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.control-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.control-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    padding: 12px 16px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.control-btn.danger {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
}

.control-btn.danger:hover {
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

/* Debug Section */
.debug-section {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px;
}

.debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.debug-header h3 {
    font-size: 16px;
    color: #8892b0;
}

.debug-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.debug-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.debug-console {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 16px;
    height: 200px;
    overflow-y: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    line-height: 1.5;
    color: #c9d1d9;
}

.debug-console .log-entry {
    margin-bottom: 4px;
    word-wrap: break-word;
}

.debug-console .log-entry .timestamp {
    color: #7c3aed;
    margin-right: 8px;
}

.debug-console .log-entry.error {
    color: #f87171;
}

.debug-console .log-entry.success {
    color: #10b981;
}

.debug-console .log-entry.warning {
    color: #f59e0b;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .info-section {
        grid-template-columns: 1fr;
    }
    
    .control-buttons {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    .header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .data-cards {
        grid-template-columns: 1fr;
    }
    
    .chart-header {
        flex-direction: column;
        gap: 12px;
    }
    
    .chart-controls {
        justify-content: center;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Firmware Update Styles */
.firmware-update {
    margin-top: 30px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.firmware-update h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #ffffff;
}

.update-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.update-option {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.update-option h4 {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 8px;
}

.update-option p {
    font-size: 14px;
    color: #8892b0;
    margin-bottom: 15px;
}

.update-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 6px;
    color: #ffffff;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.update-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.update-btn:disabled {
    background: rgba(255, 255, 255, 0.1);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Update Progress Styles */
.update-progress-container {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.progress-header h4 {
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
}

.cancel-btn {
    background: #ff6b6b;
    border: none;
    border-radius: 4px;
    color: #ffffff;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cancel-btn:hover {
    background: #ff5252;
}

.progress-bar {
    position: relative;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    height: 20px;
    margin-bottom: 15px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #00d4ff 0%, #090979 100%);
    border-radius: 10px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: 600;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.update-status {
    color: #8892b0;
    font-size: 14px;
    margin-bottom: 20px;
    text-align: center;
}

.update-steps {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
}

.step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 15px;
    left: 60%;
    width: 40%;
    height: 2px;
    background: rgba(255, 255, 255, 0.2);
}

.step.active::after {
    background: #00d4ff;
}

.step.completed::after {
    background: #51cf66;
}

.step-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    margin-bottom: 8px;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.step.active .step-icon {
    background: #00d4ff;
    border-color: #00d4ff;
    color: #000000;
}

.step.completed .step-icon {
    background: #51cf66;
    border-color: #51cf66;
    color: #000000;
}

.step.error .step-icon {
    background: #ff6b6b;
    border-color: #ff6b6b;
    color: #ffffff;
}

.step-text {
    font-size: 12px;
    color: #8892b0;
    text-align: center;
}

.step.active .step-text {
    color: #00d4ff;
    font-weight: 500;
}

.step.completed .step-text {
    color: #51cf66;
    font-weight: 500;
}

.step.error .step-text {
    color: #ff6b6b;
    font-weight: 500;
}

@media (max-width: 768px) {
    .update-options {
        grid-template-columns: 1fr;
    }
    
    .update-steps {
        flex-direction: column;
        gap: 10px;
    }
    
    .step:not(:last-child)::after {
        display: none;
    }
}