/* Base styles */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --warning: #ea580c;
    --danger: #dc2626;
    --muted: #6b7280;
    --bg: #f9fafb;
    --card-bg: #ffffff;
    --border: #e5e7eb;
    --text: #111827;
    --text-muted: #6b7280;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    line-height: 1.5;
}

/* Navigation */
.navbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}

.navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1.125rem;
}

.nav-logo {
    width: 24px;
    height: 24px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-link {
    color: var(--text);
    text-decoration: none;
    padding: 0.5rem;
}

.nav-link:hover {
    color: var(--primary);
}

.nav-logout {
    margin: 0;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Typography */
h1, h2, h3 {
    margin-top: 0;
}

h1 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

h2 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

a {
    color: var(--primary);
}

code {
    background: var(--bg);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 600;
}

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

.stat-warning .stat-value {
    color: var(--danger);
}

/* Section */
.section {
    margin-bottom: 2rem;
}

/* Table */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
}

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: var(--bg);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

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

.actions-cell {
    white-space: nowrap;
}

.error-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-cell {
    max-width: 300px;
}

.result-cell .json-clickable {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Status badges */
.status {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.status-success {
    background: #dcfce7;
    color: var(--success);
}

.status-running {
    background: #dbeafe;
    color: var(--primary);
}

.status-failed,
.status-timeout {
    background: #fee2e2;
    color: var(--danger);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background: #dcfce7;
    color: var(--success);
}

.badge-muted {
    background: var(--bg);
    color: var(--muted);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s;
}

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

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

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

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

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.btn-muted {
    background: var(--muted);
    border-color: var(--muted);
    color: white;
}

.btn-block {
    display: block;
    width: 100%;
}

/* Forms */
.form {
    max-width: 600px;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
    cursor: pointer;
}

.checkbox-label input {
    width: auto;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

/* Info grid */
.info-grid {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 0.5rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.info-grid dt {
    font-weight: 500;
    color: var(--text-muted);
}

.info-grid dd {
    margin: 0;
}

/* Task info */
.task-info {
    margin-bottom: 1.5rem;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: #fee2e2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

/* Empty state */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-container {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-container h1 {
    margin-bottom: 1.5rem;
}

.login-form .form-group {
    text-align: left;
}

/* Quick links */
.quick-links {
    display: flex;
    gap: 0.5rem;
}

/* Back link */
.back-link {
    margin-top: 1.5rem;
}

/* Inline form */
.inline-form {
    display: inline;
}

/* Error text */
.error-text {
    color: var(--danger);
}

/* Log filters */
.log-filters {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

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

.filter-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
}

.filter-group-keyword {
    flex: 1;
    min-width: 200px;
}

.filter-select,
.filter-input {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--card-bg);
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Log table */
.log-table {
    font-size: 0.875rem;
}

.log-col-time {
    width: 140px;
    white-space: nowrap;
}

.log-col-level {
    width: 80px;
}

.log-col-logger {
    width: 200px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.log-col-message {
    word-break: break-word;
}

.log-message {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.8125rem;
}

/* Log level status badges */
.status-log-debug {
    background: #e5e7eb;
    color: #6b7280;
}

.status-log-info {
    background: #dbeafe;
    color: var(--primary);
}

.status-log-warning {
    background: #fef3c7;
    color: #d97706;
}

.status-log-error {
    background: #fee2e2;
    color: var(--danger);
}

.status-log-critical {
    background: #7f1d1d;
    color: #fecaca;
}

/* Copy button */
.btn-copy {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.125rem 0.25rem;
    font-size: 0.75rem;
    opacity: 0.6;
    transition: opacity 0.15s, color 0.15s;
}

.btn-copy:hover {
    opacity: 1;
}

.btn-copy.copied {
    color: var(--success);
    opacity: 1;
}

/* JSON view button */
.btn-json {
    background: none;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    cursor: pointer;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

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

.btn-json.error-text {
    color: var(--danger);
    border-color: var(--danger);
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--card-bg);
    border-radius: 0.5rem;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

.modal-json {
    flex: 1;
    overflow: auto;
    margin: 0;
    padding: 1rem;
    background: var(--bg);
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.875rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.modal-footer {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    padding: 1rem;
    border-top: 1px solid var(--border);
}
