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

/* CSS Variables for Light Theme (default) */
:root {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f8f9fa;
    --bg-input: #ffffff;
    --text-primary: #333;
    --text-secondary: #666;
    --text-tertiary: #555;
    --text-muted: #999;
    --border-color: #ddd;
    --border-strong: #dee2e6;
    --shadow-sm: rgba(0, 0, 0, 0.1);
    --shadow-md: rgba(0, 0, 0, 0.2);
    --btn-secondary-bg: #6c757d;
    --btn-secondary-hover: #5a6268;
    --hover-bg: #f8f9fa;
    --highlight-start: #fff3cd;
    --highlight-end: #ffffff;
}

/* Dark Theme Variables */
body.dark-theme {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #262626;
    --bg-input: #262626;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-tertiary: #b0b0b0;
    --text-muted: #808080;
    --border-color: #333;
    --border-strong: #333;
    --shadow-sm: rgba(0, 0, 0, 0.3);
    --shadow-md: rgba(0, 0, 0, 0.5);
    --btn-secondary-bg: #333;
    --btn-secondary-hover: #444;
    --hover-bg: #262626;
    --highlight-start: #4a4a1a;
    --highlight-end: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

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

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

.login-card {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 40px;
    box-shadow: 0 10px 25px var(--shadow-md);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.login-card h1 {
    font-size: 28px;
    margin-bottom: 8px;
    color: var(--text-primary);
    text-align: center;
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

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

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

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s, background-color 0.3s ease;
    background-color: var(--bg-input);
    color: var(--text-primary);
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.error-message {
    color: #e74c3c;
    font-size: 14px;
    margin-bottom: 15px;
    min-height: 20px;
}

.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

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

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

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.login-footer {
    margin-top: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
}

/* Dashboard */
.dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.dashboard-header {
    background: var(--bg-secondary);
    padding: 20px 30px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.dashboard-header h1 {
    font-size: 24px;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.last-update {
    color: var(--text-secondary);
    font-size: 14px;
}

.btn-secondary {
    background: var(--btn-secondary-bg);
    color: white;
    padding: 8px 16px;
    width: auto;
    transition: background-color 0.3s ease;
}

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

/* Status Section */
.status-section {
    margin-bottom: 30px;
}

.status-section h2 {
    font-size: 20px;
    margin-bottom: 15px;
    color: var(--text-primary);
}

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

.status-card {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow-sm);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.status-card h3 {
    font-size: 18px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 10px;
}

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

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

.status-badge.error {
    background: #fff3cd;
    color: #856404;
}

/* Dark theme status badges */
body.dark-theme .status-badge.online {
    background: #1a4d2e;
    color: #4ade80;
}

body.dark-theme .status-badge.offline {
    background: #4a1a1a;
    color: #f87171;
}

body.dark-theme .status-badge.error {
    background: #4a3d1a;
    color: #fbbf24;
}

.status-info {
    font-size: 14px;
    color: var(--text-secondary);
}

.status-info p {
    margin: 5px 0;
}

/* Filters Section */
.filters-section {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px var(--shadow-sm);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.filters-section h2 {
    font-size: 20px;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 5px;
    color: var(--text-tertiary);
}

.filter-group input,
.filter-group select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    background-color: var(--bg-input);
    color: var(--text-primary);
    transition: border-color 0.3s, background-color 0.3s ease;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: #667eea;
}

.filter-actions {
    display: flex;
    gap: 10px;
}

.filter-actions .btn-primary,
.filter-actions .btn-secondary {
    width: auto;
    padding: 8px 20px;
}

/* Logs Section */
.logs-section {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow-sm);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.logs-header h3 {
    font-size: 18px;
    color: var(--text-primary);
}

.log-count {
    font-size: 14px;
    color: var(--text-secondary);
}

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

.logs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.logs-table thead {
    background: var(--bg-tertiary);
    transition: background-color 0.3s ease;
}

.logs-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-tertiary);
    border-bottom: 2px solid var(--border-color);
}

.logs-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.logs-table tbody tr:hover {
    background: var(--hover-bg);
}

.logs-table tbody tr.new-log {
    animation: highlight 2s ease-out;
}

@keyframes highlight {
    0% {
        background: var(--highlight-start);
    }
    100% {
        background: var(--highlight-end);
    }
}

.event-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.event-badge.success {
    background: #d4edda;
    color: #155724;
}

.event-badge.failed {
    background: #f8d7da;
    color: #721c24;
}

.event-badge.invalid {
    background: #fff3cd;
    color: #856404;
}

.event-badge.websocket {
    background: #d1ecf1;
    color: #0c5460;
}

.event-badge.default {
    background: #e2e3e5;
    color: #383d41;
}

/* Dark theme event badges */
body.dark-theme .event-badge.success {
    background: #1a4d2e;
    color: #4ade80;
}

body.dark-theme .event-badge.failed {
    background: #4a1a1a;
    color: #f87171;
}

body.dark-theme .event-badge.invalid {
    background: #4a3d1a;
    color: #fbbf24;
}

body.dark-theme .event-badge.websocket {
    background: #1a3a4a;
    color: #38bdf8;
}

body.dark-theme .event-badge.default {
    background: #2a2a2a;
    color: #a0a0a0;
}

.loading-row {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.no-logs-row {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* Theme Toggle Button */
.theme-toggle {
    background: var(--btn-secondary-bg);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.3s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle:hover {
    background: var(--btn-secondary-hover);
    transform: translateY(-1px);
}

.theme-toggle:active {
    transform: translateY(0);
}

.theme-icon {
    font-size: 16px;
}

/* Theme toggle for login page - smaller version */
.login-card .theme-toggle {
    padding: 6px 10px;
    font-size: 18px;
    background: transparent;
    border: 1px solid var(--border-color);
}

.login-card .theme-toggle:hover {
    background: var(--hover-bg);
    border-color: var(--text-tertiary);
}

/* Responsive */
@media (max-width: 768px) {
    .filters {
        grid-template-columns: 1fr;
    }

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

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
}
