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

:root {
    --primary: #667eea;
    --primary-dark: #5568d3;
    --secondary: #764ba2;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #334155;
}

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

/* Header */
.header {
    background: var(--surface);
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo h1 {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.version {
    background: var(--primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Navigation */
.header-nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem 1rem;
    background: var(--surface-light);
    color: var(--text);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.nav-link:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.nav-link:active {
    transform: translateY(0);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: var(--surface-light);
    font-size: 0.875rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    animation: pulse 2s infinite;
}

.connection-status.connected .status-dot {
    background: var(--success);
}

.connection-status.connecting .status-dot {
    background: var(--warning);
}

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

.btn-refresh {
    background: var(--primary);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s;
}

.btn-refresh:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

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

/* Dashboard Layout */
.dashboard {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.dashboard h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--text);
}

.dashboard section {
    margin-bottom: 3rem;
}

/* Services Info */
.services-info {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid var(--border);
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.service-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.service-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.2);
    border-color: var(--primary);
}

.service-icon {
    font-size: 2.5rem;
    text-align: center;
}

.service-card h3 {
    font-size: 1.25rem;
    color: var(--text);
    margin: 0;
}

.service-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    flex-grow: 1;
}

.service-btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
}

.service-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Overview Cards */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: all 0.3s;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border-color: var(--primary);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.card-icon {
    font-size: 1.5rem;
}

.card-title {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.card-change {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.card-change.positive {
    color: var(--success);
}

.card-change.negative {
    color: var(--danger);
}

.card-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Metrics Section */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 1.5rem;
}

.metric-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.metric-card h3 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}

.metric-items {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.metric-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.metric-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.metric-value {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
}

.metric-value.highlight {
    color: var(--primary);
}

.metric-bar {
    width: 100%;
    height: 8px;
    background: var(--surface-light);
    border-radius: 4px;
    overflow: hidden;
}

.metric-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--info));
    transition: width 0.5s ease;
}

.metric-bar-fill.ensemble {
    background: linear-gradient(90deg, var(--success), var(--primary));
}

.budget-bar {
    width: 100%;
    height: 8px;
    background: var(--surface-light);
    border-radius: 4px;
    overflow: hidden;
}

.budget-bar-fill {
    height: 100%;
    background: var(--warning);
    transition: width 0.5s ease;
}

.cost-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.875rem;
}

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

/* Charts Section */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 1.5rem;
}

.chart-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.chart-card h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.chart-card canvas {
    max-height: 300px;
}

/* Trades Table */
.table-container {
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.trades-table {
    width: 100%;
    border-collapse: collapse;
}

.trades-table thead {
    background: var(--surface-light);
}

.trades-table th {
    padding: 1rem;
    text-align: left;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.trades-table td {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.trades-table tbody tr:hover {
    background: var(--surface-light);
}

.token-name {
    font-weight: 600;
    color: var(--primary);
}

.trade-type {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.trade-type.buy {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.trade-type.sell {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.positive {
    color: var(--success);
}

.negative {
    color: var(--danger);
}

.no-data {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

/* System Health */
.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.health-item {
    background: var(--surface);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.health-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.health-status {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.health-status.healthy {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.health-status.degraded {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.health-status.unhealthy {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

/* Footer */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 1.5rem 2rem;
    margin-top: 3rem;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        padding: 1rem;
    }

    .dashboard {
        padding: 1rem;
    }

    .cards-grid,
    .metrics-grid,
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .footer-content {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .table-container {
        overflow-x: auto;
    }
}
