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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1f2937;
    --gray: #6b7280;
    --light: #f3f4f6;
    --white: #ffffff;
    --sidebar-width: 250px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--light);
    color: var(--dark);
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: var(--white);
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.logo-section {
    text-align: center;
    margin-bottom: 30px;
}

.logo-section h1 {
    font-size: 32px;
    color: var(--primary);
    margin-bottom: 8px;
}

.logo-section p {
    color: var(--gray);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--dark);
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.error-message {
    display: none;
    margin-top: 20px;
    padding: 12px;
    background: #fee2e2;
    color: var(--danger);
    border-radius: 8px;
    font-size: 14px;
}

/* Dashboard Layout */
.dashboard-container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--dark);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    font-size: 20px;
    margin-bottom: 4px;
}

.version {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.2s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

.nav-item.active {
    background: var(--primary);
    color: var(--white);
}

.nav-item .icon {
    margin-right: 12px;
    font-size: 20px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    margin-bottom: 12px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
}

.btn-logout {
    width: 100%;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.top-bar {
    background: var(--white);
    padding: 20px 30px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-bar h1 {
    font-size: 24px;
    color: var(--dark);
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-refresh {
    padding: 8px 16px;
    background: var(--white);
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-refresh:hover {
    background: var(--light);
}

.last-updated {
    font-size: 14px;
    color: var(--gray);
}

/* Content Wrapper */
.content-wrapper {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.stat-card h3 {
    font-size: 14px;
    color: var(--gray);
    margin-bottom: 12px;
    font-weight: 500;
}

.stat-value {
    font-size: 32px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 8px;
}

.stat-change {
    font-size: 14px;
    color: var(--gray);
}

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

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

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.chart-card {
    background: var(--white);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    min-height: 200px;
    max-height: 450px;
    display: flex;
    flex-direction: column;
}

.chart-card h3 {
    font-size: 16px;
    margin-bottom: 20px;
    color: var(--dark);
}

.chart-card canvas {
    max-height: 350px;
    height: 350px !important;
}

/* Activity Feed */
.activity-feed {
    max-height: 400px;
    overflow-y: auto;
}

.activity-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--light);
}

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

.activity-type {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    background: var(--light);
    color: var(--gray);
    display: inline-block;
    margin-bottom: 4px;
}

.activity-details {
    font-size: 14px;
    color: var(--dark);
    margin-bottom: 4px;
}

.activity-time {
    font-size: 12px;
    color: var(--gray);
}

/* Tables */
.table-wrapper {
    background: var(--white);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

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

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

.data-table th {
    padding: 12px;
    text-align: left;
    font-weight: 500;
    color: var(--dark);
    font-size: 14px;
}

.data-table td {
    padding: 12px;
    border-top: 1px solid var(--light);
    font-size: 14px;
}

.data-table tbody tr:hover {
    background: #fafafa;
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 20px;
    color: var(--dark);
}

.section-actions {
    display: flex;
    gap: 12px;
}

.search-input {
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    width: 250px;
}

.btn-secondary {
    padding: 8px 16px;
    background: var(--white);
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--primary);
    color: var(--white);
}

/* Tables Grid */
.tables-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.table-card {
    background: var(--white);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.table-card h4 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--dark);
}

.table-info {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--gray);
    margin-bottom: 8px;
}

/* AI Agent Section */
.ai-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.ai-card {
    background: var(--white);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ai-card h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--dark);
}

.ai-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

.ai-status.healthy {
    background: #d1fae5;
    color: var(--success);
}

.ai-status.inactive {
    background: #fee2e2;
    color: var(--danger);
}

.log-viewer {
    max-height: 300px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 12px;
    background: var(--light);
    padding: 12px;
    border-radius: 6px;
}

/* WebSocket Status */
.ws-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--white);
    padding: 8px 16px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

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

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

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
}
