:root {
  --bg-app: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --bg-sidebar-active: #059669;

  --text-main: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;

  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --primary: #059669;
  --primary-hover: #047857;
  --primary-soft: #ecfdf5;
  --primary-border: #a7f3d0;

  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --blue-border: #bfdbfe;

  --amber: #d97706;
  --amber-soft: #fffbeb;
  --amber-border: #fde68a;

  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;

  --code-bg: #0f172a;
  --code-text: #e2e8f0;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
}

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

html,
body {
  height: 100%;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-main);
  background: var(--bg-app);
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* =========================================================================
   1. TOPBAR (Compact Single-Line Header + Inline Credentials)
   ========================================================================= */
.topbar {
  height: 58px;
  background: linear-gradient(90deg, #064e3b 0%, #047857 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
}

.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.brand-title h1 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.2px;
}

.brand-title span {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  display: block;
}

.conn-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 5px 10px;
  border-radius: 8px;
}

.conn-field {
  display: flex;
  align-items: center;
  gap: 6px;
}

.conn-field label {
  font-size: 11px;
  font-weight: 600;
  color: #a7f3d0;
  white-space: nowrap;
}

.conn-field input {
  height: 28px;
  padding: 0 8px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.95);
  color: #0f172a;
  font-size: 12px;
  font-family: "JetBrains Mono", Consolas, monospace;
}

.conn-field input:focus {
  outline: none;
  border-color: #34d399;
  background: #ffffff;
}

.conn-field input.w-url {
  width: 195px;
}

.conn-field input.w-client {
  width: 105px;
}

.conn-field input.w-secret {
  width: 185px;
}

.conn-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.2);
}

.btn-top {
  height: 28px;
  padding: 0 9px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: background 0.15s;
}

.btn-top:hover {
  background: rgba(255, 255, 255, 0.26);
}

/* =========================================================================
   2. MAIN 3-COLUMN STUDIO LAYOUT (Sidebar + Center Builder + Right Inspector)
   ========================================================================= */
.studio-shell {
  flex: 1;
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr) 450px;
  overflow: hidden;
}

@media (max-width: 1360px) {
  .studio-shell {
    grid-template-columns: 220px minmax(0, 1fr) 390px;
  }
}

/* =========================================================================
   2A. LEFT SIDEBAR (Endpoints + Quick Scenarios)
   ========================================================================= */
.sidebar {
  background: var(--bg-sidebar);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #1e293b;
  overflow-y: auto;
  padding: 12px 10px;
  gap: 16px;
}

.sidebar-group-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #64748b;
  padding: 0 8px;
  margin-bottom: 6px;
}

.ep-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ep-tab {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 10px;
  color: #cbd5e1;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  transition: all 0.15s;
}

.ep-tab:hover {
  background: var(--bg-sidebar-hover);
  color: #ffffff;
}

.ep-tab.active {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.45);
  color: #ffffff;
}

.method-pill {
  font-size: 9.5px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  font-family: "JetBrains Mono", Consolas, monospace;
  margin-top: 1px;
  flex-shrink: 0;
}

.ep-tab.active .method-pill {
  background: #10b981;
  color: #064e3b;
}

.ep-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ep-name {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.25;
}

.ep-path {
  font-size: 10.5px;
  color: #64748b;
  font-family: "JetBrains Mono", Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.ep-tab.active .ep-path {
  color: #6ee7b7;
}

.sidebar-help-card {
  margin-top: auto;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px;
  font-size: 11.5px;
  color: #94a3b8;
  line-height: 1.45;
}

.sidebar-help-card strong {
  color: #e2e8f0;
  display: block;
  margin-bottom: 4px;
}

/* =========================================================================
   2B. CENTER PANE (Request URL Bar + Quick Actions + Section Sub-tabs + Form)
   ========================================================================= */
.pane-center {
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  overflow: hidden;
  border-right: 1px solid var(--border);
}

/* Postman-style URL & Send Bar at the top */
.request-url-bar {
  background: var(--bg-surface);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.url-box {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  height: 36px;
  padding: 0 10px;
  gap: 8px;
  overflow: hidden;
}

.url-method {
  background: #059669;
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 4px;
  font-family: "JetBrains Mono", Consolas, monospace;
}

.url-path {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.type-badge {
  margin-left: auto;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

/* Quick Scenario & Action Strip */
.action-bar {
  background: var(--bg-surface);
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.action-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

/* Sub-navigation tabs inside Form Builder */
.subnav-bar {
  background: #f8fafc;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.section-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
}

.sec-tab {
  padding: 9px 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.15s;
}

.sec-tab:hover {
  color: var(--text-main);
  background: rgba(15, 23, 42, 0.03);
}

.sec-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #ffffff;
}

.count-pill {
  background: #e2e8f0;
  color: #334155;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
}

.sec-tab.active .count-pill {
  background: var(--primary-soft);
  color: var(--primary);
}

/* Form Scroll Container */
.form-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 11px 16px;
  background: #fcfdfd;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-header h3 {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-body {
  padding: 14px 16px;
}

/* Grids */
.grid-1 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 1100px) {
  .grid-3,
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Form Fields & Clean Labels (No floating asterisk!) */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.lbl-left {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.req {
  color: var(--danger);
  font-weight: 700;
}

.code-hint {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 10.5px;
  font-weight: 500;
  color: #64748b;
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 4px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text-main);
  font-size: 12.5px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
  height: auto;
  padding: 8px 10px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.14);
}

.input-with-btn {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Repeater cards (doiTuong, tepDinhKem) */
.repeater-item {
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  background: #f8fafc;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.repeater-item:last-child {
  margin-bottom: 0;
}

.repeater-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 12.5px;
  color: var(--primary-hover);
}

/* File uploader box */
.file-uploader-box {
  background: var(--primary-soft);
  border: 1px dashed #34d399;
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.file-uploader-box input[type="file"] {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Raw JSON Editor View */
.json-editor-wrap {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 14px 16px;
  gap: 10px;
  overflow: hidden;
}

.json-editor-wrap.active {
  display: flex;
}

.json-textarea {
  flex: 1;
  width: 100%;
  background: var(--code-bg);
  color: #a7f3d0;
  border: 1px solid #334155;
  border-radius: var(--radius-md);
  padding: 14px;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  resize: none;
}

/* =========================================================================
   3. BUTTONS
   ========================================================================= */
.btn {
  height: 32px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  transition: all 0.15s;
}

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

.btn-sm {
  height: 28px;
  padding: 0 9px;
  font-size: 11.5px;
}

.btn-send {
  height: 36px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 2px 5px rgba(5, 150, 105, 0.25);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-outline {
  background: #ffffff;
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: #94a3b8;
  color: var(--text-main);
}

.btn-success {
  background: var(--primary-soft);
  color: var(--primary-hover);
  border-color: var(--primary-border);
}

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

.btn-amber {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: var(--amber-border);
}

.btn-amber:hover:not(:disabled) {
  background: #fef3c7;
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-border);
}

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

/* =========================================================================
   4. RIGHT PANE (Live Response, Formatted Summary, HMAC & History)
   ========================================================================= */
.pane-right {
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.res-tabs {
  display: flex;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  flex-shrink: 0;
}

.res-tab {
  padding: 11px 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.res-tab:hover {
  color: var(--text-main);
}

.res-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #ffffff;
}

.res-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.status-banner {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  border: 1px solid var(--border);
}

.status-banner.ok {
  background: var(--primary-soft);
  border-color: var(--primary-border);
}

.status-banner.err {
  background: var(--danger-soft);
  border-color: var(--danger-border);
}

.status-code {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-weight: 800;
  font-size: 13px;
}

.status-banner.ok .status-code {
  color: var(--primary-hover);
}

.status-banner.err .status-code {
  color: var(--danger);
}

.meta-text {
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: "JetBrains Mono", Consolas, monospace;
}

.summary-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
}

.summary-card h4 {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}

.kv-grid {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 5px 10px;
  font-size: 12px;
}

.kv-label {
  color: var(--text-muted);
  font-weight: 500;
}

.kv-val {
  color: var(--text-main);
  font-weight: 600;
  font-family: "JetBrains Mono", Consolas, monospace;
  word-break: break-all;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  margin-top: 6px;
  background: #ffffff;
}

.mini-table th,
.mini-table td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
}

.mini-table th {
  background: #f1f5f9;
  font-weight: 700;
  color: var(--text-secondary);
}

.code-block {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius-md);
  padding: 12px;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.history-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: border-color 0.15s, background 0.15s;
}

.history-item:hover {
  border-color: var(--primary);
  background: #ffffff;
}

.history-item .ep {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-weight: 700;
  font-size: 12px;
  color: var(--text-main);
}

.history-item .sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
