/* === HTTP request tool (Postman-like, pure frontend) === */

.http-tab {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---- Layout: collections sidebar + workspace ---- */
.http-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
@media (max-width: 900px) {
  .http-layout { grid-template-columns: 1fr; }
}

/* ---- Sidebar (collections + history) ---- */
.http-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 0;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
@media (max-width: 900px) {
  .http-side { position: relative; max-height: none; }
}
.http-side-card {
  background: #fff;
  border: 1px solid #eef2f7;
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.http-side-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  padding: 2px 4px 6px;
}
.http-side-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.http-side-icon-btn {
  border: none; background: transparent;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 4px; cursor: pointer;
  color: #64748b; font-size: 14px;
}
.http-side-icon-btn:hover { background: #f1f5f9; color: #0c4a6e; }
.http-side-icon-btn.btn-danger:hover { background: #fef2f2; color: #b91c1c; }

/* ---- Collection tree ---- */
.http-collection {
  border-radius: 6px;
  border: 1px solid transparent;
}
.http-collection.open { background: #f8fafc; }
.http-collection-head {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 6px;
  font-size: 12.5px;
  border-radius: 4px;
  cursor: pointer;
}
.http-collection-head:hover { background: #f1f5f9; }
.http-collection-name {
  flex: 1; min-width: 0;
  font-weight: 500; color: #1f2937;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.http-collection-arrow {
  font-size: 10px; color: #94a3b8; width: 12px; display: inline-block;
  transition: transform .15s ease;
}
.http-collection.open .http-collection-arrow { transform: rotate(90deg); }
.http-collection-actions {
  display: inline-flex; gap: 2px; opacity: 0; transition: opacity .15s ease;
}
.http-collection-head:hover .http-collection-actions { opacity: 1; }
.http-collection-items {
  display: none;
  flex-direction: column;
  margin: 2px 0 4px 14px;
  padding-left: 6px;
  border-left: 1px dashed #e2e8f0;
}
.http-collection.open .http-collection-items { display: flex; }
.http-item {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px; border-radius: 4px;
  font-size: 12px; color: #475569; cursor: pointer;
}
.http-item:hover { background: #f1f5f9; color: #0c4a6e; }
.http-item.active { background: #e0f2fe; color: #0369a1; }
.http-item-method {
  display: inline-grid; place-items: center;
  width: 38px; padding: 0 4px;
  border-radius: 4px; font-size: 9.5px; font-weight: 600;
  font-family: ui-monospace, monospace; letter-spacing: 0.02em;
  color: #fff;
}
.http-item-method.GET    { background: #0ea5e9; }
.http-item-method.POST   { background: #16a34a; }
.http-item-method.PUT    { background: #ea580c; }
.http-item-method.DELETE { background: #dc2626; }
.http-item-method.PATCH  { background: #7c3aed; }
.http-item-method.HEAD   { background: #64748b; }
.http-item-method.OPTIONS { background: #475569; }
.http-item-method.CONNECT { background: #475569; }
.http-item-method.TRACE  { background: #475569; }
.http-item-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, monospace; font-size: 11.5px;
}
.http-item-actions { display: inline-flex; gap: 2px; opacity: 0; transition: opacity .15s ease; }
.http-item:hover .http-item-actions { opacity: 1; }
.http-side-empty {
  padding: 8px 4px; color: #94a3b8; font-size: 12px;
}
.http-side-link {
  border: none; background: transparent;
  font-size: 12px; color: #0369a1; cursor: pointer; padding: 0;
}
.http-side-link:hover { text-decoration: underline; }

/* ---- History list ---- */
.http-history-item {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px; border-radius: 4px;
  font-size: 11.5px; color: #475569; cursor: pointer;
}
.http-history-item:hover { background: #f1f5f9; color: #0c4a6e; }
.http-history-item .http-history-time {
  color: #94a3b8; font-size: 10.5px; flex-shrink: 0;
}
.http-history-item .http-history-url {
  flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, monospace;
}
.http-history-status {
  display: inline-grid; place-items: center;
  min-width: 26px; height: 16px; padding: 0 4px;
  border-radius: 4px; font-size: 9.5px; font-weight: 600;
  font-family: ui-monospace, monospace; letter-spacing: 0.02em;
  color: #fff;
}
.http-history-status.s2 { background: #16a34a; }
.http-history-status.s3 { background: #0ea5e9; }
.http-history-status.s4 { background: #ea580c; }
.http-history-status.s5 { background: #dc2626; }
.http-history-status.err { background: #b91c1c; }

/* ---- Workspace ---- */
.http-workspace {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* ---- URL bar ---- */
.http-urlbar {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
}
.http-method {
  height: 36px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #fff;
  font-size: 12.5px;
  font-weight: 600;
  font-family: ui-monospace, monospace;
  color: #0c4a6e;
  cursor: pointer;
  outline: none;
  min-width: 110px;
}
.http-method:focus { border-color: #38bdf8; box-shadow: 0 0 0 3px rgba(56,189,248,0.15); }
.http-method.GET    { color: #0369a1; }
.http-method.POST   { color: #16a34a; }
.http-method.PUT    { color: #ea580c; }
.http-method.DELETE { color: #dc2626; }
.http-method.PATCH  { color: #7c3aed; }
.http-method.HEAD,
.http-method.OPTIONS,
.http-method.CONNECT,
.http-method.TRACE  { color: #475569; }

.http-url-input-wrap {
  flex: 1; min-width: 220px;
  position: relative;
  display: flex; align-items: stretch;
}
.http-url-input {
  flex: 1; min-width: 0;
  height: 36px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #fff;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  color: #1f2937;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.http-url-input:focus { border-color: #38bdf8; box-shadow: 0 0 0 3px rgba(56,189,248,0.15); }
.http-url-input.invalid { border-color: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,0.15); }
.http-url-input.datalist-shown { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.http-url-datalist {
  position: absolute; left: 0; right: 0; top: 100%;
  background: #fff; border: 1px solid #e2e8f0;
  border-top: none;
  border-radius: 0 0 6px 6px;
  z-index: 20; max-height: 220px; overflow-y: auto;
  box-shadow: 0 6px 16px -8px rgba(15,23,42,0.18);
}
.http-url-datalist-item {
  padding: 6px 10px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  cursor: pointer;
  color: #1f2937;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.http-url-datalist-item:hover { background: #f1f5f9; color: #0c4a6e; }
.http-url-icon-btn {
  border: 1px solid #e2e8f0;
  background: #fff;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 6px;
  cursor: pointer;
  color: #475569;
}
.http-url-icon-btn:hover { background: #f1f5f9; color: #0c4a6e; }
.http-url-icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.http-send-btn {
  height: 36px;
  padding: 0 18px;
  border-radius: 6px;
  border: 1px solid #0ea5e9;
  background: #0ea5e9;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s ease;
}
.http-send-btn:hover { background: #0284c7; border-color: #0284c7; }
.http-send-btn:disabled { background: #bae6fd; border-color: #bae6fd; cursor: not-allowed; }
.http-cancel-btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 13px;
  cursor: pointer;
}
.http-cancel-btn:hover { background: #fee2e2; }

.http-spinner {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.45);
  border-top-color: #fff;
  animation: spin 1.1s linear infinite;
}

.http-meta-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 11.5px; color: #64748b;
  padding: 0 4px;
}
.http-meta-row .http-meta-strong { color: #1f2937; font-weight: 500; }
.http-url-status {
  font-family: ui-monospace, monospace;
}
.http-url-status.error { color: #b91c1c; }
.http-url-status.warn  { color: #b45309; }

/* ---- Tabs (Params/Headers/Auth/Body) ---- */
.http-tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid #eef2f7;
  background: #fff;
  border-radius: 8px 8px 0 0;
  padding: 0 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.http-tabs::-webkit-scrollbar { display: none; }
.http-tab-btn {
  border: none; background: transparent;
  padding: 10px 14px;
  font-size: 13px; color: #64748b;
  border-bottom: 2px solid transparent;
  cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.http-tab-btn:hover { color: #0c4a6e; }
.http-tab-btn.active {
  color: #0369a1;
  border-bottom-color: #0ea5e9;
  font-weight: 500;
}
.http-tab-badge {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 16px; padding: 0 5px;
  border-radius: 999px;
  background: #e0f2fe; color: #0369a1;
  font-size: 10px; font-weight: 600;
}

.http-pane {
  background: #fff;
  border: 1px solid #eef2f7;
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 80px;
}

/* ---- KV table (params / headers / form rows) ---- */
.http-kv-wrap { overflow-x: auto; border: 1px solid #eef2f7; border-radius: 6px; }
.http-kv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  background: #fff;
}
.http-kv-table th {
  padding: 6px 8px;
  background: #f8fafc;
  color: #64748b;
  font-weight: 500;
  text-align: left;
  border-bottom: 1px solid #eef2f7;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.http-kv-table td {
  padding: 4px 6px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.http-kv-table tr:last-child td { border-bottom: none; }
.http-kv-table input[type="text"] {
  width: 100%;
  height: 26px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font-size: 12px;
  font-family: ui-monospace, monospace;
  color: #1f2937;
  outline: none;
}
.http-kv-table input[type="text"]:focus {
  border-color: #38bdf8;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(56,189,248,0.15);
}
.http-kv-table input[type="text"]:disabled { color: #cbd5e1; }
.http-kv-checkbox {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  cursor: pointer;
}
.http-kv-del {
  border: none; background: transparent;
  color: #94a3b8; cursor: pointer;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 4px;
}
.http-kv-del:hover { background: #fef2f2; color: #b91c1c; }

.http-kv-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding-top: 4px;
}

/* ---- Body tab segmented controls ---- */
.http-seg {
  display: inline-flex; gap: 0;
  background: #f1f5f9;
  border-radius: 6px;
  padding: 2px;
  flex-wrap: wrap;
}
.http-seg-btn {
  border: none; background: transparent;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  color: #475569;
  cursor: pointer;
}
.http-seg-btn:hover { color: #0c4a6e; }
.http-seg-btn.active {
  background: #fff;
  color: #0369a1;
  box-shadow: 0 1px 2px rgba(15,23,42,0.06);
}

.http-textarea {
  width: 100%;
  min-height: 180px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-family: ui-monospace, "SFMono-Regular", "Consolas", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  color: #1f2937;
  background: #fff;
  resize: vertical;
  outline: none;
}
.http-textarea:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56,189,248,0.15);
}
.http-textarea-error { border-color: #ef4444; }
.http-textarea-error-msg {
  font-size: 11.5px; color: #b91c1c;
  margin-top: 4px;
}

.http-body-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}

/* ---- Auth pane ---- */
.http-auth-row {
  display: grid; grid-template-columns: 110px 1fr;
  gap: 10px; align-items: center;
}
.http-auth-row > label {
  font-size: 12px; color: #64748b;
}
.http-input {
  height: 32px; padding: 0 10px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #fff;
  font-size: 13px;
  color: #1f2937;
  outline: none;
}
.http-input:focus { border-color: #38bdf8; box-shadow: 0 0 0 3px rgba(56,189,248,0.15); }

.http-file-input {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: #475569;
}

/* ---- Response pane ---- */
.http-response {
  display: flex; flex-direction: column;
  background: #fff;
  border: 1px solid #eef2f7;
  border-radius: 8px;
  min-height: 240px;
}
.http-response-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #eef2f7;
  background: #f8fafc;
  border-radius: 8px 8px 0 0;
}
.http-response-status {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px;
}
.http-status-badge {
  display: inline-grid; place-items: center;
  min-width: 36px; height: 22px; padding: 0 8px;
  border-radius: 6px;
  font-size: 12px; font-weight: 600;
  font-family: ui-monospace, monospace;
  color: #fff;
}
.http-status-badge.s2 { background: #16a34a; }
.http-status-badge.s3 { background: #0ea5e9; }
.http-status-badge.s4 { background: #ea580c; }
.http-status-badge.s5 { background: #dc2626; }
.http-status-badge.err { background: #b91c1c; }
.http-response-status .http-status-text { color: #475569; }
.http-response-meta {
  display: inline-flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-size: 12px; color: #64748b;
}
.http-response-meta b { color: #1f2937; font-weight: 500; }

.http-response-tabs {
  display: flex; gap: 0;
  padding: 0 10px;
  border-bottom: 1px solid #eef2f7;
  overflow-x: auto;
  scrollbar-width: none;
}
.http-response-tabs::-webkit-scrollbar { display: none; }
.http-response-tab {
  border: none; background: transparent;
  padding: 8px 12px;
  font-size: 12.5px; color: #64748b;
  border-bottom: 2px solid transparent;
  cursor: pointer; white-space: nowrap;
}
.http-response-tab:hover { color: #0c4a6e; }
.http-response-tab.active {
  color: #0369a1;
  border-bottom-color: #0ea5e9;
  font-weight: 500;
}

.http-response-body {
  flex: 1; min-height: 200px;
  display: flex; flex-direction: column;
}
.http-response-body-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid #f1f5f9;
}
.http-response-search {
  flex: 1; min-width: 180px;
  height: 28px; padding: 0 8px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  background: #fff;
  font-size: 12px;
  outline: none;
}
.http-response-search:focus { border-color: #38bdf8; box-shadow: 0 0 0 2px rgba(56,189,248,0.15); }
.http-response-content {
  flex: 1; min-height: 180px;
  padding: 0;
  overflow: auto;
  font-family: ui-monospace, "SFMono-Regular", "Consolas", monospace;
  font-size: 12.5px;
  line-height: 1.6;
  color: #1f2937;
  background: #fff;
}
.http-response-content pre {
  margin: 0; padding: 10px 12px;
  white-space: pre-wrap; word-break: break-all;
}
.http-response-empty {
  padding: 40px 12px; text-align: center;
  color: #94a3b8; font-size: 13px;
}
.http-response-error {
  padding: 14px 12px;
  font-size: 13px; color: #b91c1c;
}
.http-response-error-title { font-weight: 500; margin-bottom: 4px; }

.http-response-headers,
.http-response-request {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: ui-monospace, monospace;
}
.http-response-headers th,
.http-response-request th {
  padding: 6px 10px;
  background: #f8fafc;
  color: #64748b;
  text-align: left;
  font-weight: 500;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid #eef2f7;
  white-space: nowrap;
}
.http-response-headers td,
.http-response-request td {
  padding: 5px 10px;
  border-bottom: 1px solid #f1f5f9;
  word-break: break-all;
  vertical-align: top;
}
.http-response-headers td.val { color: #1f2937; }
.http-response-request td.val { color: #1f2937; white-space: pre-wrap; }

/* ---- Highlighted body search ---- */
.http-search-mark {
  background: #fef08a;
  color: #854d0e;
  border-radius: 2px;
  padding: 0 1px;
}

/* ---- Save dialog ---- */
.http-save-modal {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.5);
  display: grid; place-items: center;
  z-index: 100;
}
.http-save-modal-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  width: min(440px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 12px;
}
.http-save-modal-card h3 { margin: 0; font-size: 16px; color: #0c4a6e; }
.http-save-modal-row {
  display: flex; flex-direction: column; gap: 4px;
}
.http-save-modal-row label { font-size: 12px; color: #64748b; }
.http-save-modal-actions {
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ---- Misc ---- */
.http-muted { color: #94a3b8; font-size: 11px; }
.http-helper-text { color: #94a3b8; font-size: 11.5px; }
.http-tip { font-size: 11px; color: #94a3b8; }
.http-chips {
  display: inline-flex; flex-wrap: wrap; gap: 4px;
}
.http-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 11px;
  cursor: pointer;
  border: 1px solid transparent;
}
.http-chip:hover { background: #e2e8f0; }
.http-chip.active {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}

/* Mobile tweaks */
@media (max-width: 600px) {
  .http-method { min-width: 0; flex: 1; }
  .http-url-input-wrap { flex: 1 1 100%; }
  .http-send-btn, .http-cancel-btn { flex: 1; }
}
