/* ==================== Global Styles ==================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --success-color: #16a34a;
    --warning-color: #ea580c;
    --danger-color: #dc2626;
    --info-color: #0284c7;
    --dark-color: #1f2937;
    --light-color: #f3f4f6;
    --border-color: #d1d5db;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--dark-color);
}

.container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
}

/* ==================== Header ==================== */

.header {
    background: white;
    padding: 2rem 1.5rem;
    box-shadow: var(--shadow-lg);
    border-bottom: 4px solid var(--primary-color);
    margin-bottom: 1.5rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header h1 {
    font-size: 2rem;
    color: var(--dark-color);
    margin: 0;
}

.status-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--dark-color);
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

.status-indicator.connected {
    background: var(--success-color);
}

.status-indicator.disconnected {
    background: var(--danger-color);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ==================== Control Panel ==================== */

.control-panel {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1.5rem;
    background: white;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    align-items: center;
}

.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-start {
    background: var(--success-color);
    color: white;
}

.btn-start:hover:not(:disabled) {
    background: #15803d;
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.btn-stop {
    background: var(--danger-color);
    color: white;
}

.btn-stop:hover:not(:disabled) {
    background: #b91c1c;
    box-shadow: var(--shadow-lg);
}

.btn-info {
    background: var(--info-color);
    color: white;
}

.btn-info:hover:not(:disabled) {
    background: #0369a1;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.control-info {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-left: auto;
}

.control-info label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.control-info input {
    width: 60px;
    padding: 0.375rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

/* ==================== Dashboard ==================== */

main.dashboard {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.dashboard-section {
    background: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
}

.dashboard-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--dark-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.75rem;
}

/* ==================== Metric Cards ==================== */

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.metric-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1.5rem;
    border-radius: 0.5rem;
    color: white;
    text-align: center;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.metric-card.highlighted {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.metric-card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    opacity: 0.9;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0.5rem 0;
    font-family: 'Courier New', monospace;
}

.metric-value.small {
    font-size: 1rem;
}

.metric-label {
    font-size: 0.75rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ==================== Charts ==================== */

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.chart-container {
    background: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
}

.chart-container h3 {
    margin-bottom: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.chart-container canvas {
    max-height: 300px;
}

/* ==================== Alerts ==================== */

.alerts-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.alert {
    padding: 1rem;
    border-radius: 0.375rem;
    border-left: 4px solid;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.alert.warning {
    background: #fef3c7;
    border-left-color: var(--warning-color);
    color: #b45309;
}

.alert.error {
    background: #fee2e2;
    border-left-color: var(--danger-color);
    color: #991b1b;
}

.alert.info {
    background: #e0f2fe;
    border-left-color: var(--info-color);
    color: #0c4a6e;
}

.alert-content {
    flex: 1;
}

.alert-time {
    font-size: 0.75rem;
    opacity: 0.7;
}

.alert-message {
    font-weight: 600;
    margin-top: 0.25rem;
}

.alert-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.alert-close:hover {
    opacity: 1;
}

.no-alerts {
    color: var(--success-color);
    text-align: center;
    padding: 2rem;
    font-weight: 600;
}

/* ==================== Footer ==================== */

.footer {
    background: white;
    padding: 1.5rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
    color: #6b7280;
    font-size: 0.875rem;
    margin-top: auto;
}

/* ==================== Responsive ==================== */

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .status-info {
        flex-wrap: wrap;
    }

    .control-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .control-panel .btn {
        width: 100%;
    }

    .control-info {
        margin-left: 0;
        width: 100%;
    }

    .metric-grid {
        grid-template-columns: 1fr 1fr;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0;
    }

    .header {
        padding: 1rem;
    }

    .dashboard-section {
        padding: 1rem;
    }

    .metric-grid {
        grid-template-columns: 1fr;
    }

    .metric-card {
        padding: 1rem;
    }

    .metric-value {
        font-size: 1.5rem;
    }

    .header h1 {
        font-size: 1.25rem;
    }

    .dashboard-section h2 {
        font-size: 1rem;
    }
}

/* ==================== Loading & Animation ==================== */

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0,0,0,.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
}
