/* Senate Components — buttons, cards, badges, tables, forms, dialogs, etc. */

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

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
}

h1 { font-size: clamp(28px, 3.5vw, 42px); }
h2 { font-size: clamp(22px, 2.8vw, 32px); }
h3 { font-size: 18px; }
h4 { font-size: 16px; }

a { color: var(--accent); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--accent-h); }

code, pre, kbd, samp {
  font-family: var(--font-mono);
}

pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 16px 20px;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.5;
}

code {
  background: var(--surface);
  padding: 2px 6px;
  border-radius: var(--r-badge);
  font-size: 0.9em;
}

pre code {
  background: none;
  padding: 0;
}

/* --- Utility text --- */
.text-secondary { color: var(--text-2); }
.text-muted, .text-sm { color: var(--text-3); font-size: 14px; }
.text-mono { font-family: var(--font-mono); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-uppercase { text-transform: uppercase; letter-spacing: 0.04em; }
.text-sm { font-size: 14px; }
.fw-bold { font-weight: 700; }
.fs-5 { font-size: 1.25rem; }

/* --- Buttons --- */
.btn-primary,
.btn-outline,
.btn-danger-outline,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 22px;
  border-radius: var(--r-btn);
  border: none;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  text-decoration: none;
  line-height: 1;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-h);
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn-outline:hover {
  background: var(--accent-light);
}

.btn-danger-outline {
  background: transparent;
  color: var(--error);
  border: 1.5px solid var(--error);
}
.btn-danger-outline:hover {
  background: var(--error-light);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  padding: 8px 14px;
}
.btn-ghost:hover {
  color: var(--text);
}

.btn-sm {
  font-size: 13px;
  padding: 6px 14px;
}

.btn-dark {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
}
.btn-dark:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* --- Cards --- */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 24px 28px;
  transition: border-color var(--t-normal), box-shadow var(--t-normal);
}

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

.card-accent {
  position: relative;
}
.card-accent::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  background: var(--accent);
  border-radius: var(--r-rule);
}

.card-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.card-text {
  color: var(--text-2);
  font-size: 14px;
}

.card-surface {
  background: var(--surface);
}

/* --- Badges --- */
.badge-ok,
.badge-warn,
.badge-error,
.badge-info,
.badge-neutral {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: var(--r-badge);
  line-height: 1.4;
}

.badge-ok { background: var(--success-light); color: var(--success); }
.badge-warn { background: var(--warning-light); color: var(--warning); }
.badge-error { background: var(--error-light); color: var(--error); }
.badge-info { background: var(--accent-light); color: var(--accent); }
.badge-neutral { background: var(--surface-2); color: var(--text-2); }

.badge-role {
  font-size: 10px;
}

/* --- Tables --- */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

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

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

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* --- Forms --- */
.label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

.input, select.input, textarea.input {
  font-family: var(--font-body);
  font-size: 14px;
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.input:focus, select.input:focus, textarea.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

.input::placeholder {
  color: var(--text-3);
}

.form-text {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 4px;
}

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

.invalid-feedback {
  color: var(--error);
  font-size: 13px;
  margin-top: 4px;
}
.invalid-feedback.d-block {
  display: block;
}

/* --- Dialogs (replace Bootstrap modals) --- */
dialog {
  border: none;
  border-radius: var(--r-card);
  padding: 0;
  max-width: 480px;
  width: 90vw;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
  background: var(--bg);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.dialog-header h3 {
  font-size: 18px;
}

.dialog-body {
  padding: 20px 24px;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 24px 20px;
}

.dialog-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-3);
  padding: 4px;
  line-height: 1;
}
.dialog-close:hover {
  color: var(--text);
}

/* --- Progress bars --- */
.progress-custom {
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width var(--t-normal);
  background: var(--accent);
}
.progress-fill.fill-ok { background: var(--success); }
.progress-fill.fill-warn { background: var(--warning); }
.progress-fill.fill-error { background: var(--error); }

/* --- Accordion (details/summary) --- */
details {
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  margin-bottom: 8px;
}

details summary {
  padding: 14px 20px;
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  font-size: 14px;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

details summary::-webkit-details-marker { display: none; }

details summary::after {
  content: '+';
  font-size: 18px;
  color: var(--text-3);
  transition: transform var(--t-fast);
}

details[open] summary::after {
  content: '−';
}

details > :not(summary) {
  padding: 0 20px 16px;
}

/* --- Alerts --- */
.alert-custom {
  padding: 14px 20px;
  border-radius: var(--r-btn);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.alert-success { background: var(--success-light); color: var(--success); }
.alert-warning { background: var(--warning-light); color: var(--warning); }
.alert-danger { background: var(--error-light); color: var(--error); }
.alert-info { background: var(--accent-light); color: var(--accent); }

.alert-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  padding: 0;
  line-height: 1;
}
.alert-close:hover { opacity: 1; }

/* --- Toasts --- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  animation: fadeUp 0.3s ease;
}

/* --- Spinner --- */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* --- Pagination --- */
.pagination-custom {
  display: flex;
  gap: 4px;
  justify-content: center;
  list-style: none;
  padding: 0;
  margin: 24px 0;
}

.pagination-custom a,
.pagination-custom span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  color: var(--text);
  text-decoration: none;
  transition: all var(--t-fast);
}

.pagination-custom a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pagination-custom .active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pagination-custom .disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* --- Dropdown (user menu) --- */
.dropdown {
  position: relative;
}

.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 8px;
  min-width: 180px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  z-index: 100;
  padding: 6px 0;
}

.dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-item {
  display: block;
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  transition: background var(--t-fast);
}

.dropdown-item:hover {
  background: var(--surface);
  color: var(--text);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

/* --- Key display (API keys) --- */
.key-display {
  font-family: var(--font-mono);
  background: var(--surface);
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  word-break: break-all;
  font-size: 13px;
}

/* --- Animations --- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.6); }
}

.fade-up { animation: fadeUp 0.4s ease both; }
.fade-up-1 { animation-delay: 0.08s; }
.fade-up-2 { animation-delay: 0.16s; }
.fade-up-3 { animation-delay: 0.24s; }

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease-in-out infinite;
}

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: 80px 20px;
}
.empty-state h3 {
  font-size: 18px;
  color: var(--text-2);
  margin-bottom: 8px;
}
.empty-state p {
  font-size: 14px;
  color: var(--text-3);
  max-width: 360px;
  margin: 0 auto 20px;
}

/* --- Evaluation-specific --- */
.opinion-card {
  font-size: 14px;
}

.opinion-card details summary {
  cursor: pointer;
  user-select: none;
}

.opinion-card pre {
  font-size: 13px;
  max-height: 300px;
  overflow-y: auto;
}
