/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Dark Theme Colors */
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --bg-card: #1e1e1e;
    --bg-hover: #2d2d2d;

    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-muted: #666666;

    /* Accent Colors */
    --accent-green: #00C851;
    --accent-blue: #007bff;
    --accent-purple: #6f42c1;
    --accent-orange: #fd7e14;
    --accent-red: #dc3545;
    --accent-yellow: #ffc107;

    /* Status Colors */
    --status-success: #00C851;
    --status-warning: #ffc107;
    --status-danger: #dc3545;
    --status-info: #17a2b8;

    /* Border Colors */
    --border-primary: #333333;
    --border-secondary: #444444;

    /* Shadow */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.5);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;

    /* Typography */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
    --font-size-4xl: 2.5rem;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Dashboard Container */
.dashboard-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.dashboard-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    padding: var(--spacing-md) var(--spacing-xl);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.logo svg {
    transition: var(--transition-normal);
}

.logo:hover svg {
    transform: rotate(180deg);
}

.title-section h1 {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 400;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.connection-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-secondary);
}

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

.status-indicator.online {
    background: var(--status-success);
    animation: none;
}

.status-indicator.offline {
    background: var(--status-danger);
}

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

.last-updated {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* Main Content */
.dashboard-main {
    flex: 1;
    padding: var(--spacing-xl);
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Metrics Section */
.metrics-section {
    margin-bottom: var(--spacing-2xl);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-lg);
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-green);
    transition: var(--transition-normal);
}

.metric-card.primary::before { background: var(--accent-green); }
.metric-card.secondary::before { background: var(--accent-blue); }
.metric-card.accent::before { background: var(--accent-purple); }
.metric-card.warning::before { background: var(--accent-orange); }

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-secondary);
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.metric-header h3 {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-icon {
    font-size: var(--font-size-lg);
    opacity: 0.7;
}

.metric-value {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
    font-variant-numeric: tabular-nums;
}

.metric-change {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

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

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

.metric-change.neutral {
    color: var(--text-secondary);
}

/* Performance Section */
.performance-section {
    margin-bottom: var(--spacing-2xl);
}

.performance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
}

.performance-card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    transition: var(--transition-normal);
}

.performance-card:hover {
    border-color: var(--border-secondary);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.card-header h3 {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-primary);
}

.value-large {
    font-size: var(--font-size-4xl);
    font-weight: 700;
    color: var(--accent-green);
    font-variant-numeric: tabular-nums;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin: var(--spacing-md) 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-blue));
    border-radius: var(--radius-sm);
    transition: width 0.5s ease;
}

.threshold-info {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    text-align: center;
}

/* Charts Section */
.charts-section {
    margin-bottom: var(--spacing-2xl);
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: var(--spacing-lg);
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    transition: var(--transition-normal);
}

.chart-card:hover {
    border-color: var(--border-secondary);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.chart-header h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.chart-controls {
    display: flex;
    gap: var(--spacing-sm);
}

.chart-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.chart-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.chart-btn.active {
    background: var(--accent-green);
    color: white;
    border-color: var(--accent-green);
}

.legend {
    display: flex;
    gap: var(--spacing-md);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

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

.legend-color.orders { background: var(--accent-green); }
.legend-color.trades { background: var(--accent-blue); }

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-container canvas {
    max-height: 100%;
    max-width: 100%;
}

/* Status Section */
.status-section {
    margin-bottom: var(--spacing-2xl);
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
}

.status-card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    transition: var(--transition-normal);
}

.status-card:hover {
    border-color: var(--border-secondary);
}

.status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.status-header h3 {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-primary);
}

.health-indicator {
    display: flex;
    align-items: center;
}

.health-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.health-status.healthy {
    background: rgba(0, 200, 81, 0.1);
    color: var(--status-success);
}

.health-status.warning {
    background: rgba(255, 193, 7, 0.1);
    color: var(--status-warning);
}

.health-status.danger {
    background: rgba(220, 53, 69, 0.1);
    color: var(--status-danger);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.service-status {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.service-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) 0;
}

.service-name {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.service-state {
    font-size: var(--font-size-lg);
}

.service-state.healthy { color: var(--status-success); }
.service-state.warning { color: var(--status-warning); }
.service-state.danger { color: var(--status-danger); }

/* Symbols List */
.symbols-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.symbol-item {
    padding: var(--spacing-md) 0;
    border-bottom: 1px solid var(--border-primary);
}

.symbol-item:last-child {
    border-bottom: none;
}

.symbol-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
}

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

.symbol-volume {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.symbol-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.symbol-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-blue));
    border-radius: var(--radius-sm);
    transition: width 0.5s ease;
}

/* Alerts */
.alerts-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    max-height: 300px;
    overflow-y: auto;
}

.alert-item {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    border-left: 3px solid transparent;
}

.alert-item.info {
    background: rgba(23, 162, 184, 0.1);
    border-left-color: var(--status-info);
}

.alert-item.warning {
    background: rgba(255, 193, 7, 0.1);
    border-left-color: var(--status-warning);
}

.alert-item.danger {
    background: rgba(220, 53, 69, 0.1);
    border-left-color: var(--status-danger);
}

.alert-icon {
    font-size: var(--font-size-lg);
    line-height: 1;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.alert-time {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* Footer */
.dashboard-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-primary);
    padding: var(--spacing-lg) var(--spacing-xl);
    margin-top: auto;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.footer-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.footer-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.footer-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

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

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 10, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-lg);
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-tertiary);
    border-top: 3px solid var(--accent-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .dashboard-main {
        padding: var(--spacing-lg);
    }

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

    .chart-container {
        height: 250px;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: var(--spacing-md);
        text-align: center;
    }

    .header-actions {
        flex-direction: column;
        gap: var(--spacing-sm);
    }

    .dashboard-main {
        padding: var(--spacing-md);
    }

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

    .performance-grid {
        grid-template-columns: 1fr;
    }

    .status-grid {
        grid-template-columns: 1fr;
    }

    .chart-header {
        flex-direction: column;
        gap: var(--spacing-md);
        align-items: flex-start;
    }

    .footer-content {
        flex-direction: column;
        gap: var(--spacing-md);
        text-align: center;
    }

    .metric-value {
        font-size: var(--font-size-2xl);
    }

    .value-large {
        font-size: var(--font-size-3xl);
    }
}

@media (max-width: 480px) {
    .dashboard-header {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .dashboard-main {
        padding: var(--spacing-sm);
    }

    .dashboard-footer {
        padding: var(--spacing-md);
    }

    .metric-card,
    .performance-card,
    .chart-card,
    .status-card {
        padding: var(--spacing-md);
    }

    .chart-container {
        height: 200px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus,
.chart-btn:focus {
    outline: 2px solid var(--accent-green);
    outline-offset: 2px;
}

/* Custom scrollbar */
.alerts-list::-webkit-scrollbar {
    width: 6px;
}

.alerts-list::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.alerts-list::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: var(--radius-sm);
}

.alerts-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}