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

:root {
    --bg-primary: #0f0f1e;
    --bg-secondary: #1a1a2e;
    --bg-elevated: #232340;
    --bg-hover: #2a2a45;

    --text-primary: #e8e8f0;
    --text-secondary: #9b9bb0;
    --text-muted: #6b6b80;

    --border-color: #2d2d4a;
    --border-hover: #3d3d5a;

    --accent-primary: #4a90ff;
    --accent-hover: #5c9eff;

    --level-debug: #6b7280;
    --level-info: #3b82f6;
    --level-warn: #f59e0b;
    --level-error: #ef4444;

    --success: #10b981;
    --danger: #ef4444;

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

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 24px 0;
    margin-bottom: 32px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(26, 26, 46, 0.85);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo-icon {
    font-size: 32px;
    filter: drop-shadow(0 0 12px rgba(74, 144, 255, 0.5));
}

.logo-text {
    background: linear-gradient(135deg, var(--accent-primary), #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-stats {
    display: flex;
    gap: 32px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* Main */
.main {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 48px;
}

/* Card */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-md);
    transition: border-color var(--transition-base);
}

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

.section-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text-primary);
}

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

.section-header .section-title {
    margin-bottom: 0;
}

/* Form */
.log-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group input,
.form-group select,
.form-group textarea {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 15px;
    color: var(--text-primary);
    font-family: inherit;
    transition: all var(--transition-base);
}

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

.form-group textarea {
    resize: vertical;
    min-height: 80px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    line-height: 1.5;
}

.form-group select {
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    font-family: inherit;
    white-space: nowrap;
}

.btn-icon {
    font-size: 18px;
    line-height: 1;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(74, 144, 255, 0.3);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 144, 255, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid transparent;
    padding: 6px 12px;
    font-size: 13px;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
}

/* Loading & Empty States */
.loading-state,
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg-elevated);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Table */
.logs-table-wrapper {
    overflow-x: auto;
    margin: 0 -32px;
    padding: 0 32px;
}

.logs-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.logs-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.logs-table th {
    background: var(--bg-elevated);
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    text-align: left;
    border-bottom: 2px solid var(--border-color);
}

.logs-table th:first-child {
    border-top-left-radius: var(--radius-sm);
}

.logs-table th:last-child {
    border-top-right-radius: var(--radius-sm);
}

.logs-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    vertical-align: middle;
}

.logs-table tbody tr {
    transition: background-color var(--transition-fast);
}

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

.col-id {
    width: 80px;
    font-variant-numeric: tabular-nums;
}

.col-level {
    width: 100px;
}

.col-source {
    width: 150px;
}

.col-timestamp {
    width: 180px;
    font-variant-numeric: tabular-nums;
}

.col-actions {
    width: 100px;
    text-align: center;
}

/* Log Level Badge */
.log-level {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.log-level-debug {
    background: rgba(107, 114, 128, 0.15);
    color: var(--level-debug);
    border: 1px solid rgba(107, 114, 128, 0.3);
}

.log-level-info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--level-info);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.log-level-warn {
    background: rgba(245, 158, 11, 0.15);
    color: var(--level-warn);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.log-level-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--level-error);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.log-level-icon {
    font-size: 8px;
}

/* Log Message */
.log-message {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    color: var(--text-primary);
    line-height: 1.5;
    max-width: 600px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.log-source {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    color: var(--text-secondary);
    font-size: 13px;
}

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

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.pagination-info {
    font-size: 14px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.pagination-info span {
    font-weight: 600;
    color: var(--text-primary);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    transform: translateY(120%);
    opacity: 0;
    transition: all var(--transition-base);
    z-index: 1000;
    max-width: 400px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

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

.toast.error {
    background: var(--danger);
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }

    .header {
        padding: 16px 0;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .logo {
        font-size: 24px;
    }

    .header-stats {
        gap: 24px;
    }

    .card {
        padding: 24px 16px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .logs-table-wrapper {
        margin: 0 -16px;
        padding: 0 16px;
    }

    .logs-table th,
    .logs-table td {
        padding: 12px 8px;
        font-size: 13px;
    }

    .col-id,
    .col-timestamp,
    .col-source {
        display: none;
    }

    .log-message {
        max-width: 200px;
    }
}

/* Prompt Result */
.prompt-result {
    margin-top: 20px;
    padding: 16px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-sm);
}

.prompt-result p {
    color: var(--text-primary);
    font-size: 14px;
}

.prompt-result a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
}

.prompt-result a:hover {
    text-decoration: underline;
}

/* Disabled state */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button:disabled:hover {
    transform: none;
}
