/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #f5f7fa; color: #1a1a2e; line-height: 1.6; }

/* Nav */
.nav { display: flex; align-items: center; gap: 1.5rem; padding: 0.75rem 2rem; background: #1a1a2e; color: #fff; }
.nav-brand { font-weight: 700; font-size: 1.1rem; }
.nav-links { display: flex; gap: 1rem; flex: 1; }
.nav-links a { color: #a0aec0; text-decoration: none; font-size: 0.9rem; padding: 0.25rem 0.5rem; border-radius: 4px; transition: all 0.2s; }
.nav-links a:hover { color: #fff; background: rgba(255,255,255,0.1); }
.nav-user { display: flex; align-items: center; gap: 0.75rem; font-size: 0.85rem; color: #a0aec0; }

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

/* Cards */
.card { background: #fff; border-radius: 8px; padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.card h2 { margin-bottom: 1rem; font-size: 1.25rem; color: #1a1a2e; }
.card h3 { margin-bottom: 0.75rem; font-size: 1.1rem; color: #2d3748; }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.5rem; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.35rem; font-size: 0.9rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 0.6rem 0.75rem; border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 0.9rem; font-family: inherit; transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.form-group textarea { min-height: 120px; resize: vertical; font-family: "SF Mono", "Fira Code", monospace; font-size: 0.85rem; }
.form-group .help { font-size: 0.8rem; color: #6b7280; margin-top: 0.25rem; }

/* Buttons */
.btn { display: inline-block; padding: 0.55rem 1.2rem; border: none; border-radius: 6px; font-size: 0.9rem; font-weight: 500; cursor: pointer; text-decoration: none; transition: all 0.2s; }
.btn-primary { background: #4f46e5; color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-success { background: #059669; color: #fff; }
.btn-success:hover { background: #047857; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: #e5e7eb; color: #374151; }
.btn-secondary:hover { background: #d1d5db; }
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid #e5e7eb; font-size: 0.9rem; }
th { font-weight: 600; background: #f9fafb; color: #374151; }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* Metrics */
.metric { display: flex; justify-content: space-between; padding: 0.5rem 0; border-bottom: 1px solid #f3f4f6; }
.metric-label { font-weight: 500; }
.metric-value { font-family: monospace; }
.metric-pass { color: #059669; }
.metric-fail { color: #dc2626; }

/* Badge */
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 12px; font-size: 0.75rem; font-weight: 600; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-admin { background: #ede9fe; color: #5b21b6; }
.badge-editor { background: #dbeafe; color: #1e40af; }

/* Login */
.login-wrapper { display: flex; justify-content: center; align-items: center; min-height: 80vh; }
.login-card { width: 100%; max-width: 400px; }

/* Chat */
.chat-layout { display: grid; grid-template-columns: 280px 1fr; gap: 1.5rem; min-height: 70vh; }
.chat-sidebar { background: #fff; border-radius: 8px; padding: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,0.08); overflow-y: auto; }
.chat-sidebar .session-item { padding: 0.6rem 0.75rem; border-radius: 6px; cursor: pointer; margin-bottom: 0.25rem; font-size: 0.85rem; transition: background 0.15s; }
.chat-sidebar .session-item:hover { background: #f3f4f6; }
.chat-sidebar .session-item.active { background: #ede9fe; color: #5b21b6; }
.chat-main { display: flex; flex-direction: column; background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.chat-messages { flex: 1; overflow-y: auto; padding: 1.5rem; }
.chat-input-area { padding: 1rem 1.5rem; border-top: 1px solid #e5e7eb; display: flex; gap: 0.75rem; }
.chat-input-area textarea { flex: 1; resize: none; min-height: 44px; max-height: 120px; }
.msg { margin-bottom: 1rem; }
.msg-user { text-align: right; }
.msg-user .msg-bubble { background: #4f46e5; color: #fff; display: inline-block; padding: 0.6rem 1rem; border-radius: 12px 12px 0 12px; max-width: 80%; text-align: left; }
.msg-assistant .msg-bubble { background: #f3f4f6; display: inline-block; padding: 0.6rem 1rem; border-radius: 12px 12px 12px 0; max-width: 80%; }
.msg-system .msg-bubble { background: #fef3c7; display: inline-block; padding: 0.4rem 0.75rem; border-radius: 6px; font-size: 0.85rem; color: #92400e; }
.config-diff { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; padding: 0.75rem; margin-top: 0.5rem; font-family: monospace; font-size: 0.85rem; }
.config-diff .old { color: #dc2626; text-decoration: line-through; }
.config-diff .new { color: #059669; }

/* Audit */
.audit-entry { padding: 1rem; border-left: 3px solid #4f46e5; margin-bottom: 0.75rem; background: #fafbfc; border-radius: 0 6px 6px 0; }
.audit-entry .audit-meta { font-size: 0.8rem; color: #6b7280; margin-bottom: 0.35rem; }
.audit-entry .audit-change { font-family: monospace; font-size: 0.85rem; }
.audit-entry a.restricted { color: #9ca3af; cursor: not-allowed; text-decoration: none; }

/* Preview */
.preview-content { background: #fff; padding: 2rem; border: 1px solid #e5e7eb; border-radius: 8px; }
.preview-content h1 { font-size: 1.75rem; margin-bottom: 1rem; }
.preview-content h2 { font-size: 1.35rem; margin: 1.5rem 0 0.75rem; }
.preview-content p { margin-bottom: 0.75rem; }
.preview-content ul, .preview-content ol { margin-bottom: 0.75rem; padding-left: 1.5rem; }
.preview-content a { color: #4f46e5; }

/* Responsive */
@media (max-width: 768px) {
    .nav { flex-wrap: wrap; padding: 0.75rem 1rem; }
    .nav-links { order: 3; width: 100%; overflow-x: auto; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .chat-layout { grid-template-columns: 1fr; }
}
