/* Stygian Plugin Popup Styles */

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

body {
  width: 500px;
  min-height: 400px;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    sans-serif;
  background: #f5f7fa;
  color: #333;
}

.container {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: white;
}

/* Header */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-content h1 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 2px;
}

.subtitle {
  font-size: 12px;
  opacity: 0.9;
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid #e0e6ed;
  background: #f9fafb;
}

.tab-btn {
  flex: 1;
  padding: 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #666;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}

.tab-btn:hover {
  background: #f0f2f5;
  color: #333;
}

.tab-btn.active {
  color: #667eea;
  border-bottom-color: #667eea;
  background: white;
}

/* Tab Content */
.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.tab-content.active {
  display: block;
}

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

.tab-header h2 {
  font-size: 16px;
  font-weight: 600;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: #555;
}

.input,
.textarea,
select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d0d7e0;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: white;
  color: #333;
  transition: border-color 0.2s;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row .input {
  flex: 1;
}

.hint {
  color: #667085;
  font-size: 12px;
  margin-top: 6px;
}

.compact-toggle-row {
  margin-top: -4px;
}

.checkbox-row {
  align-items: center;
  color: #445;
  cursor: pointer;
  display: flex;
  gap: 8px;
}

.input:focus,
.textarea:focus,
select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.textarea {
  resize: vertical;
  min-height: 80px;
  font-family:
    "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New",
    monospace;
}

/* Buttons */
.btn {
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #5568d3;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
  background: #e0e6ed;
  color: #666;
}

.btn-secondary:hover:not(:disabled) {
  background: #d0d7e0;
}

.btn-success {
  background: #48bb78;
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: #38a169;
}

.btn-danger {
  background: #f56565;
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #e53e3e;
}

.btn-small {
  padding: 4px 8px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button-group {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.button-group .btn {
  flex: 1;
}

/* Templates List */
.templates-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.template-card {
  background: white;
  border: 1px solid #e0e6ed;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}

.template-card:hover {
  border-color: #667eea;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.template-info h3 {
  font-size: 14px;
  margin-bottom: 4px;
}

.template-info p {
  font-size: 12px;
  color: #666;
  margin-bottom: 6px;
}

.template-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: #999;
}

.template-actions {
  display: flex;
  gap: 6px;
}

/* Regions List */
.regions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: #f9fafb;
  border-radius: 6px;
  border: 1px dashed #d0d7e0;
}

.region-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  background: white;
  border-radius: 4px;
  border-left: 3px solid #667eea;
  font-size: 12px;
}

.region-name {
  font-weight: 500;
  color: #333;
}

.region-count {
  font-size: 11px;
  color: #999;
}

/* Results */
.results-container {
  margin-top: 16px;
}

.results-panel {
  background: #f9fafb;
  border: 1px solid #e0e6ed;
  border-radius: 6px;
  padding: 12px;
}

.results-panel h3 {
  font-size: 13px;
  margin-bottom: 8px;
}

.results-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.summary-chip {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  color: #334155;
  font-size: 11px;
  padding: 4px 8px;
}

.results-table-wrap {
  background: white;
  border: 1px solid #e0e6ed;
  border-radius: 4px;
  margin-bottom: 10px;
  max-height: 220px;
  overflow: auto;
}

.results-table {
  border-collapse: collapse;
  font-size: 11px;
  min-width: 100%;
}

.results-table th,
.results-table td {
  border-bottom: 1px solid #edf2f7;
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

.results-table th {
  background: #f8fafc;
  position: sticky;
  top: 0;
}

.results-panel pre {
  background: white;
  border: 1px solid #e0e6ed;
  border-radius: 4px;
  padding: 10px;
  font-size: 11px;
  overflow-x: auto;
  max-height: 200px;
  margin-bottom: 8px;
}

.results-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.results-errors {
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: 4px;
  color: #7f1d1d;
  font-size: 11px;
  margin-bottom: 10px;
  padding: 8px 10px;
}

.results-errors ul {
  margin-left: 16px;
  margin-top: 6px;
}

.results-details {
  margin-top: 8px;
}

.results-details summary {
  color: #475569;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
}

/* Status Messages */
.status-message {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  display: none;
}

.status-message.success {
  display: block;
  background: #c6f6d5;
  color: #22543d;
  border: 1px solid #9ae6b4;
}

.status-message.error {
  display: block;
  background: #fed7d7;
  color: #742a2a;
  border: 1px solid #fc8181;
}

.status-message.info {
  display: block;
  background: #bee3f8;
  color: #2c5282;
  border: 1px solid #90cdf4;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 20px;
  color: #999;
  font-size: 13px;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #d0d7e0;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #b0b7c0;
}

/* Connection Status */
.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}

.connection-status.connected {
  background: #c6f6d5;
  color: #276749;
  border: 1px solid #9ae6b4;
}

.connection-status.disconnected {
  background: #fed7d7;
  color: #9b2c2c;
  border: 1px solid #fc8181;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.connected .status-dot {
  background: #38a169;
}

.disconnected .status-dot {
  background: #e53e3e;
}

/* Input row (input + button side by side) */
.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-row .input {
  flex: 1;
}

/* Hint text */
.hint {
  font-size: 11px;
  color: #888;
  margin-top: 4px;
}

.connection-diagnostics {
  font-size: 12px;
  color: #666;
  margin-top: 6px;
}

.hint code {
  background: #f0f0f0;
  padding: 1px 4px;
  border-radius: 3px;
  font-family: monospace;
}

/* ── Draft recovery banner ─────────────────────────────────────────────────── */
.draft-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fffbeb;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: 13px;
}
.draft-banner-body {
  flex: 1;
}
.draft-banner-label {
  color: #92400e;
  font-size: 12px;
  margin-left: 6px;
}
.draft-banner-actions {
  display: flex;
  gap: 6px;
}

/* ── Recording active badge ────────────────────────────────────────────────── */
.recording-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff5f5;
  border: 1px solid #fc8181;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  margin-bottom: 10px;
}
.recording-pulse {
  width: 10px;
  height: 10px;
  background: #f87171;
  border-radius: 50%;
  animation: pulse-anim 1.5s ease-in-out infinite;
}
@keyframes pulse-anim {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}
.badge-count {
  background: #fee2e2;
  color: #7f1d1d;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
}

/* ── Regions header & undo ─────────────────────────────────────────────────── */
.regions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.regions-header h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
}

/* ── Quick-action buttons ──────────────────────────────────────────────────── */
.quick-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.btn-quick {
  padding: 5px 10px;
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: #4338ca;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.btn-quick:hover {
  background: #e0e7ff;
}
.btn-quick.active {
  background: #6366f1;
  color: #fff;
  border-color: #4338ca;
}

/* ── Label optional ────────────────────────────────────────────────────────── */
.label-optional {
  font-size: 11px;
  color: #94a3b8;
  font-weight: normal;
  margin-left: 4px;
}

/* ── Modal overlay & modals ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: #fff;
  border-radius: 10px;
  width: 320px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px 10px;
  border-bottom: 1px solid #e2e8f0;
}
.modal-header h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #94a3b8;
  line-height: 1;
  padding: 0 4px;
}
.modal-close:hover {
  color: #475569;
}
.modal-body {
  padding: 14px 16px;
}
.modal-footer {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid #e2e8f0;
  justify-content: flex-end;
}

/* ── Per-tab status (sticky) ───────────────────────────────────────────────── */
.status-message.sticky {
  display: block !important;
}

/* ── Region timeline ───────────────────────────────────────────────────────── */
.region-timeline-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-left: 3px solid #94a3b8;
  border-radius: 6px;
  padding: 7px 8px;
  margin-bottom: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.region-confidence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.region-item-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}
.btn-icon {
  padding: 2px 6px;
  background: transparent;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
}
.btn-icon:hover {
  background: #f1f5f9;
  color: #1e293b;
}
