/* ==========================================================================
   TANGAN KANAN MDT - MINIMALIST DESIGN SYSTEM
   ========================================================================== */

:root {
  --bg-app: #090b0f;
  --bg-card: #11141a;
  --bg-subtle: #171b23;
  --bg-input: #0c0e13;

  --border-hairline: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --border-focus: #3b82f6;

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-subtle: #6b7280;

  --accent-primary: #ffffff;
  --accent-primary-text: #090b0f;
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-layout {
  max-width: 1560px;
  margin: 0 auto;
  padding: 20px 24px 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100vh;
}

/* --------------------------------------------------------------------------
   NAVBAR (MINIMALIST)
   -------------------------------------------------------------------------- */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 0 16px 0;
  border-bottom: 1px solid var(--border-hairline);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  background: var(--text-main);
  color: var(--bg-app);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  user-select: none;
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.2px;
  color: var(--text-main);
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-subtle);
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* --------------------------------------------------------------------------
   PILL BUTTONS & MINIMAL INPUTS
   -------------------------------------------------------------------------- */
.pill-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  color: var(--text-main);
  padding: 7px 13px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.pill-btn:hover {
  background: #1e232e;
  border-color: var(--border-hover);
  color: #fff;
}

.key-pill {
  position: relative;
}

.key-indicator-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-subtle);
  transition: background 0.2s ease;
}

.key-indicator-dot.active {
  background: var(--accent-emerald);
}

.key-indicator-dot.warning {
  background: var(--accent-amber);
}

.select-wrapper select {
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  color: var(--text-main);
  padding: 7px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

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

.select-wrapper select:focus {
  border-color: var(--border-focus);
}

/* --------------------------------------------------------------------------
   WORKSPACE GRID (2 COLUMNS)
   -------------------------------------------------------------------------- */
.workspace-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  flex: 1;
}

@media (max-width: 1024px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.badge-tag {
  font-size: 11px;
  font-family: var(--font-mono);
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: 4px;
}

.card-meta {
  font-size: 12px;
  color: var(--text-subtle);
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   PRESETS BAR
   -------------------------------------------------------------------------- */
.presets-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--border-hairline);
  background: var(--bg-input);
  flex-wrap: wrap;
}

.presets-title {
  font-size: 11px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-right: 4px;
}

.chip-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  background: #202632;
  border-color: var(--border-hover);
  color: var(--text-main);
}

.chip-clear {
  margin-left: auto;
  color: var(--accent-amber);
}

.chip-clear:hover {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
}

/* --------------------------------------------------------------------------
   INPUT EDITOR
   -------------------------------------------------------------------------- */
.editor-area {
  flex: 1;
  display: flex;
  padding: 16px 18px;
  background: var(--bg-input);
}

textarea#incidentInput {
  width: 100%;
  min-height: 420px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  resize: none;
}

textarea#incidentInput::placeholder {
  color: var(--text-subtle);
  font-size: 13.5px;
}

.card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
}

.shortcut-legend {
  font-size: 12px;
  color: var(--text-subtle);
}

kbd {
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   PRIMARY & ACTION BUTTONS
   -------------------------------------------------------------------------- */
.primary-btn {
  background: var(--accent-primary);
  color: var(--accent-primary-text);
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.primary-btn:hover:not(:disabled) {
  opacity: 0.92;
  transform: translateY(-1px);
}

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

.action-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-btn:hover {
  background: #202632;
  border-color: var(--border-hover);
  color: var(--text-main);
}

.action-btn.active-copied {
  color: var(--accent-emerald) !important;
  border-color: var(--accent-emerald) !important;
  background: rgba(16, 185, 129, 0.08) !important;
}

/* --------------------------------------------------------------------------
   OUTPUT VIEW SWITCH & STATUS BAR
   -------------------------------------------------------------------------- */
.view-switch {
  display: flex;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hairline);
}

.switch-btn {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.switch-btn.active {
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.header-actions {
  display: flex;
  gap: 8px;
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: var(--bg-input);
  border-bottom: 1px solid var(--border-hairline);
  font-size: 12px;
  color: var(--text-subtle);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-subtle);
}

.status-bar.working .status-dot {
  background: var(--accent-blue);
  animation: pulse-dot 1.2s infinite ease-in-out;
}

.status-bar.done .status-dot {
  background: var(--accent-emerald);
}

.status-bar.error .status-dot {
  background: var(--accent-red);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.85); }
}

.key-notice {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-blue);
}

/* --------------------------------------------------------------------------
   OUTPUT BODY (SPLIT & UNIFIED)
   -------------------------------------------------------------------------- */
.output-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 18px;
  background: var(--bg-input);
  overflow-y: auto;
}

.tab-pane {
  display: none;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.tab-pane.active {
  display: flex;
}

.report-box {
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease;
}

.report-box:focus-within {
  border-color: var(--border-hover);
}

.box-header {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #141720;
}

.box-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.copy-sub-btn {
  background: transparent;
  border: 1px solid var(--border-hairline);
  color: var(--text-subtle);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.copy-sub-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--border-hover);
}

.copy-sub-btn.active-copied {
  color: var(--accent-emerald) !important;
  border-color: var(--accent-emerald) !important;
}

.box-textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.6;
  padding: 10px 14px;
  resize: vertical;
}

.box-textarea::placeholder {
  color: var(--text-subtle);
  font-size: 13px;
}

.unified-raw-textarea {
  width: 100%;
  flex: 1;
  min-height: 480px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.6;
  resize: none;
  white-space: pre-wrap;
}

.unified-raw-textarea::placeholder {
  color: var(--text-subtle);
}

/* --------------------------------------------------------------------------
   MODAL / ROLLING KEYS SHEET
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-sheet {
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

.modal-sheet-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

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

.modal-sheet-body {
  padding: 20px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.field-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.field-label-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.link-muted {
  font-size: 12px;
  color: var(--text-subtle);
  text-decoration: none;
  transition: color 0.15s ease;
}

.link-muted:hover {
  color: var(--text-main);
  text-decoration: underline;
}

textarea.keys-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-hairline);
  color: var(--text-main);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  outline: none;
  resize: vertical;
}

textarea.keys-input:focus {
  border-color: var(--border-focus);
}

.keys-help {
  font-size: 12px;
  color: var(--text-subtle);
}

.key-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-pill {
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-num {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.stat-label {
  font-size: 11px;
  color: var(--text-subtle);
}

.active-key-preview {
  background: var(--bg-input);
  border: 1px solid var(--border-hairline);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.preview-label {
  color: var(--text-subtle);
}

.preview-val {
  font-family: var(--font-mono);
  color: var(--text-main);
  margin-right: auto;
}

.modal-sheet-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-hairline);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-right {
  display: flex;
  gap: 10px;
}

.btn-ghost-danger {
  background: transparent;
  border: 1px solid transparent;
  color: var(--accent-red);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

/* History Modal items */
.history-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-subtle);
  font-family: var(--font-mono);
}

.history-snippet {
  font-size: 12.5px;
  color: var(--text-muted);
  max-height: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-item-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.empty-state {
  text-align: center;
  color: var(--text-subtle);
  padding: 32px 0;
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   MINIMAL TOAST
   -------------------------------------------------------------------------- */
.minimal-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1c212c;
  border: 1px solid var(--border-hover);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
}

.minimal-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}
