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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    color: #2c3e50;
    line-height: 1.6;
}

/* Connection Status */
.connection-status {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    padding: 10px 20px;
    border-radius: 25px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    transition: all 0.3s ease;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e74c3c;
    animation: pulse 2s infinite;
}

.connection-status.connected .status-indicator {
    background: #27ae60;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(231, 76, 60, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
    }
}

.connection-status.connected .status-indicator {
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0% {
        box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(39, 174, 96, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(39, 174, 96, 0);
    }
}

/* Header */
.main-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.main-header h1 {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

/* Control Panel */
.control-panel {
    background: white;
    margin: 20px;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.summary-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.summary-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.12);
}

.summary-card h3 {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.summary-value {
    font-size: 2rem;
    font-weight: bold;
    color: #2c3e50;
}

.controls {
    display: flex;
    align-items: center;
    gap: 15px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

.controls label {
    font-weight: 600;
    color: #495057;
}

.controls select {
    padding: 8px 15px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    background: white;
    font-size: 14px;
    transition: border-color 0.3s ease;
    cursor: pointer;
}

.controls select:focus {
    outline: none;
    border-color: #667eea;
}

/* Table Container */
.table-container {
    margin: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

/* Table Styles */
.stations-table {
    width: 100%;
    border-collapse: collapse;
}

.stations-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.stations-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stations-table tbody tr {
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.3s ease;
}

.stations-table tbody tr:hover {
    background-color: #f8f9fa;
}

.stations-table tbody tr.disconnected {
    background-color: #f8f9fa;
    opacity: 0.7;
}

.stations-table td {
    padding: 15px;
    color: #495057;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.connected {
    background: #d4edda;
    color: #155724;
}

.status-badge.disconnected {
    background: #f8d7da;
    color: #721c24;
}

/* Connector Status */
.connector-status {
    font-size: 0.9rem;
    line-height: 1.4;
}

.connector-item {
    padding: 2px 0;
}

.connector-available {
    color: #27ae60;
}

.connector-charging {
    color: #3498db;
    font-weight: 600;
}

.connector-faulted {
    color: #e74c3c;
}

.connector-preparing {
    color: #f39c12;
}

/* Error Messages */
.error-messages {
    max-height: 33vh;
    overflow-y: auto;
    font-size: 0.85rem;
    font-family: 'Consolas', 'Monaco', monospace;
    background: #f8f9fa;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    width: 250px;
}

.error-message {
    margin-bottom: 5px;
    padding: 3px 0;
    word-wrap: break-word;
}

.error-message.error {
    color: #e74c3c;
}

.error-message.warning {
    color: #f39c12;
}

.error-message .timestamp {
    color: #7f8c8d;
    margin-right: 5px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn {
    padding: 6px 14px;
    border: none;
    border-radius: 5px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-start {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
}

.btn-start:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(39, 174, 96, 0.4);
}

.btn-stop {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
}

.btn-stop:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.4);
}

.btn-update {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
}

.btn-update:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.btn-clear {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    color: white;
}

.btn-clear:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(149, 165, 166, 0.4);
}

/* No Stations Message */
.no-stations {
    padding: 60px 20px;
    text-align: center;
    color: #7f8c8d;
}

.no-stations p {
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.no-stations .hint {
    font-size: 0.9rem;
    color: #95a5a6;
}

/* Footer */
.main-footer {
    background: #2c3e50;
    color: white;
    text-align: center;
    padding: 20px;
    margin-top: 40px;
}

.main-footer p {
    font-size: 0.9rem;
}

#wsUrl {
    color: #3498db;
    font-family: 'Consolas', 'Monaco', monospace;
}

/* Scrollbar Styles */
.error-messages::-webkit-scrollbar {
    width: 6px;
}

.error-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.error-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.error-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .stations-table {
        font-size: 0.9rem;
    }
    
    .stations-table th,
    .stations-table td {
        padding: 10px;
    }
}

@media (max-width: 768px) {
    .main-header h1 {
        font-size: 1.5rem;
    }
    
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .connection-status {
        top: 10px;
        right: 10px;
        padding: 8px 15px;
        font-size: 0.9rem;
    }
    
    .table-container {
        overflow-x: auto;
    }
    
    .stations-table {
        min-width: 900px;
    }
}

/* Loading Animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Transition Animations */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Battery Indicators (Phase 2) */
.battery-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
    transition: all 0.3s ease;
}

.battery-good {
    background: rgba(46, 213, 115, 0.15);
    color: #10b981;
}

.battery-warning {
    background: rgba(251, 191, 36, 0.15);
    color: #f59e0b;
}

.battery-low {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.battery-critical {
    background: rgba(220, 38, 38, 0.2);
    color: #dc2626;
    font-weight: 700;
}

.battery-unknown {
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
}

.battery-stale {
    opacity: 0.6;
}

.battery-indicator.pulse {
    animation: batteryPulse 1.5s infinite;
}

@keyframes batteryPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Battery Alert Banner */
.battery-alert-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    z-index: 2000;
    animation: slideDown 0.3s ease;
    font-weight: 600;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.battery-alert-banner.warning {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
}

.battery-alert-banner.low {
    background: linear-gradient(135deg, #f87171, #ef4444);
    color: white;
}

.battery-alert-banner.critical {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    animation: slideDown 0.3s ease, alertFlash 2s infinite;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes alertFlash {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.85;
    }
}

.battery-alert-banner .alert-icon {
    font-size: 1.5em;
}

.battery-alert-banner .alert-message {
    flex: 1;
    text-align: center;
}

.battery-alert-banner .dismiss-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1.2em;
    transition: background 0.2s;
}

.battery-alert-banner .dismiss-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Charging Metrics Display (Phase 3) */
.metrics-container {
    margin-top: 15px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 12px;
    border: 1px solid #dee2e6;
    animation: fadeIn 0.3s ease;
}

.metrics-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #dee2e6;
}

.metrics-header h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 8px;
}

.metrics-header .charging-icon {
    font-size: 1.2em;
    animation: chargingPulse 2s infinite;
    color: #28a745;
}

@keyframes chargingPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.metric-card {
    background: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.metric-card:hover::before {
    transform: scaleX(1);
}

.metric-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.metric-label {
    font-size: 0.75rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
    font-weight: 600;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2c3e50;
    transition: all 0.3s ease;
    line-height: 1.2;
}

.metric-value.updating {
    animation: valueUpdate 0.3s ease;
}

@keyframes valueUpdate {
    0% {
        transform: scale(1);
        color: #2c3e50;
    }
    50% {
        transform: scale(1.05);
        color: #667eea;
    }
    100% {
        transform: scale(1);
        color: #2c3e50;
    }
}

.metric-unit {
    font-size: 0.9rem;
    color: #6c757d;
    font-weight: 400;
    margin-left: 2px;
}

.metric-trend {
    font-size: 0.75rem;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.metric-trend.up {
    color: #28a745;
}

.metric-trend.down {
    color: #dc3545;
}

.metric-trend.stable {
    color: #6c757d;
}

/* Power Gauge */
.power-gauge {
    width: 100%;
    max-width: 250px;
    margin: 20px auto;
}

.gauge-container {
    position: relative;
    padding-bottom: 50%;
}

.gauge-bg {
    position: absolute;
    width: 100%;
    height: 200%;
    border: 8px solid #e9ecef;
    border-bottom: none;
    border-radius: 100% 100% 0 0;
    transform-origin: bottom center;
}

.gauge-fill {
    position: absolute;
    width: 100%;
    height: 200%;
    border: 8px solid transparent;
    border-bottom: none;
    border-radius: 100% 100% 0 0;
    transform-origin: bottom center;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.gauge-fill.low-power {
    border-color: #28a745;
}

.gauge-fill.medium-power {
    border-color: #ffc107;
}

.gauge-fill.high-power {
    border-color: #fd7e14;
}

.gauge-fill.max-power {
    border-color: #dc3545;
}

.gauge-center {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    background: white;
    padding: 8px 15px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.gauge-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #2c3e50;
    transition: all 0.3s ease;
}

.gauge-label {
    font-size: 0.75rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Progress Bars */
.progress-bar-container {
    margin-top: 15px;
}

.progress-bar-label {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 10px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.progress-fill.soc-low {
    background: linear-gradient(90deg, #dc3545, #c82333);
}

.progress-fill.soc-medium {
    background: linear-gradient(90deg, #ffc107, #e0a800);
}

.progress-fill.soc-high {
    background: linear-gradient(90deg, #28a745, #218838);
}

.progress-fill.soc-full {
    background: linear-gradient(90deg, #20c997, #17a2b8);
}

/* Charging Stats */
.charging-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    margin-top: 15px;
}

.stat-item {
    text-align: center;
    padding: 10px;
    border-right: 1px solid #dee2e6;
    transition: all 0.3s ease;
}

.stat-item:last-child {
    border-right: none;
}

.stat-item:hover {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
}

.stat-label {
    font-size: 0.7rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    transition: color 0.3s ease;
}

.stat-item:hover .stat-value {
    color: #667eea;
}

/* Charging Timer */
.charging-timer {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

.charging-timer:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.timer-icon {
    animation: timerSpin 4s linear infinite;
}

@keyframes timerSpin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Energy Flow Indicator */
.energy-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    margin-top: 15px;
}

.flow-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
    color: #6c757d;
}

.flow-arrow {
    width: 30px;
    height: 2px;
    background: linear-gradient(90deg, transparent, #667eea, transparent);
    position: relative;
    overflow: hidden;
}

.flow-arrow::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 100%;
    background: #667eea;
    animation: flowAnimation 1.5s infinite;
}

@keyframes flowAnimation {
    0% {
        left: -10px;
    }
    100% {
        left: 100%;
    }
}

/* Real-time Update Animations */
.metrics-container.updating {
    animation: metricsUpdate 0.3s ease;
}

@keyframes metricsUpdate {
    0% {
        background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    }
    50% {
        background: linear-gradient(135deg, #f0f8ff, #e6f3ff);
    }
    100% {
        background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    }
}

/* No Data State */
.no-metrics-data {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    margin-top: 15px;
}

.no-metrics-data .icon {
    font-size: 3rem;
    margin-bottom: 10px;
    opacity: 0.3;
}

.no-metrics-data .message {
    font-size: 1rem;
    font-weight: 500;
}

.no-metrics-data .hint {
    font-size: 0.85rem;
    margin-top: 5px;
    color: #adb5bd;
}

/* Responsive Metrics */
@media (max-width: 768px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .metric-value {
        font-size: 1.2rem;
    }

    .gauge-value {
        font-size: 1.5rem;
    }

    .charging-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-item {
        border-right: none;
        border-bottom: 1px solid #dee2e6;
    }

    .stat-item:nth-last-child(-n+2) {
        border-bottom: none;
    }
}