/* ============================================================
   RT Webhook for CF7 – Admin Styles
   ============================================================ */

/* Root & Layout */
#rtwc-admin-root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.rtwc-app {
  max-width: 1100px;
}

/* Header */
.rtwc-header {
  background: #fff;
  border-bottom: 1px solid #ddd;
  margin: -10px -20px 24px;
  padding: 0 20px;
}

.rtwc-header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
}

.rtwc-header-inner h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1d2327;
  margin: 0;
  flex: 1;
}

.rtwc-header-icon {
  font-size: 1.6rem !important;
  color: #2271b1;
}

.rtwc-new-btn,
.rtwc-back-btn {
  margin-left: auto;
  white-space: nowrap;
}

/* Notice */
.rtwc-notice {
  padding: 10px 16px;
  border-radius: 4px;
  margin-bottom: 18px;
  font-weight: 500;
}

.rtwc-notice--success {
  background: #d1fae5;
  border-left: 4px solid #10b981;
  color: #065f46;
}

.rtwc-notice--error {
  background: #fee2e2;
  border-left: 4px solid #ef4444;
  color: #991b1b;
}

/* Loading */
.rtwc-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 30px 0;
  color: #777;
}

/* Empty state */
.rtwc-empty-state {
  text-align: center;
  padding: 60px 20px;
  background: #fff;
  border: 1px dashed #ccc;
  border-radius: 6px;
}

.rtwc-empty-icon {
  font-size: 3rem !important;
  color: #ccc;
  display: block;
  margin-bottom: 12px;
}

.rtwc-empty-state h2 {
  color: #555;
  margin-bottom: 8px;
}

/* List */
.rtwc-list table {
  background: #fff;
}

.rtwc-url-cell {
  font-size: 12px;
  background: #f4f4f4;
  padding: 2px 6px;
  border-radius: 3px;
  display: inline-block;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.rtwc-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: #e5e7eb;
  color: #374151;
}

.rtwc-badge--post { background: #dbeafe; color: #1e40af; }
.rtwc-badge--get  { background: #d1fae5; color: #065f46; }
.rtwc-badge--put  { background: #fef3c7; color: #92400e; }

.rtwc-status {
  font-size: 12px;
  font-weight: 600;
}

.rtwc-status--publish { color: #16a34a; }
.rtwc-status--draft   { color: #9ca3af; }

.rtwc-actions {
  white-space: nowrap;
}

.rtwc-delete-btn {
  color: #dc2626 !important;
  border-color: #dc2626 !important;
}

.rtwc-delete-btn:hover {
  background: #dc2626 !important;
  color: #fff !important;
}

/* Editor */
.rtwc-editor {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
}

.rtwc-editor-titlebar {
  display: flex;
  align-items: flex-end;
  gap: 24px;
  padding: 20px 24px 0;
  background: #f8f9fa;
  border-bottom: 1px solid #e5e7eb;
  flex-wrap: wrap;
}

.rtwc-title-field {
  flex: 1;
  min-width: 250px;
}

.rtwc-title-input {
  width: 100%;
  font-size: 1rem !important;
}

.rtwc-status-toggle {
  padding-bottom: 4px;
}

.rtwc-toggle-group {
  display: inline-flex;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
}

.rtwc-toggle {
  padding: 6px 14px;
  border: none;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  color: #555;
  transition: all 0.15s;
}

.rtwc-toggle.active {
  background: #2271b1;
  color: #fff;
}

/* Tabs */
.rtwc-tabs {
  display: flex;
  border-bottom: 1px solid #ddd;
  background: #f8f9fa;
  padding: 0 24px;
}

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

.rtwc-tab:hover { color: #2271b1; }

.rtwc-tab--active {
  color: #2271b1;
  border-bottom-color: #2271b1;
  background: #fff;
}

/* Tab content */
.rtwc-tab-content {
  padding: 24px;
  min-height: 280px;
}

.rtwc-section-desc {
  margin-bottom: 16px !important;
}

.rtwc-form-table th {
  width: 200px;
  padding: 15px 10px 15px 0;
  vertical-align: top;
}

.rtwc-form-table td {
  padding: 12px 0;
}

/* Method selector */
.rtwc-method-group {
  display: inline-flex;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
}

.rtwc-method-btn {
  padding: 6px 18px;
  border: none;
  border-right: 1px solid #ddd;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: #555;
  transition: all 0.15s;
}

.rtwc-method-btn:last-child { border-right: none; }

.rtwc-method-btn--post.active { background: #dbeafe; color: #1e40af; }
.rtwc-method-btn--get.active  { background: #d1fae5; color: #065f46; }
.rtwc-method-btn--put.active  { background: #fef3c7; color: #92400e; }

/* Mapping / Headers table */
.rtwc-mapping-table { margin-bottom: 12px; }
.rtwc-mapping-table td { vertical-align: middle; }
.rtwc-mapping-table select,
.rtwc-mapping-table input { width: 100%; }

.rtwc-remove-btn {
  color: #dc2626 !important;
}

.rtwc-empty-table {
  padding: 20px;
  background: #f9f9f9;
  border: 1px dashed #ddd;
  border-radius: 4px;
  margin-bottom: 12px;
  color: #888;
  text-align: center;
}

.rtwc-hint {
  color: #9a6700;
  background: #fefce8;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  margin-top: 10px !important;
}

/* Conditional logic */
.rtwc-toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.rtwc-toggle-label {
  font-size: 14px;
  font-weight: 500;
}

/* Toggle switch */
.rtwc-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.rtwc-switch input { display: none; }

.rtwc-switch-slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 24px;
  cursor: pointer;
  transition: 0.2s;
}

.rtwc-switch-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.rtwc-switch input:checked + .rtwc-switch-slider {
  background: #2271b1;
}

.rtwc-switch input:checked + .rtwc-switch-slider::before {
  transform: translateX(20px);
}

.rtwc-cond-builder {
  background: #f8f9fa;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 20px;
}

.rtwc-cond-desc {
  margin: 0 0 14px;
  font-weight: 600;
}

.rtwc-cond-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.rtwc-cond-cell {
  flex: 1;
  min-width: 160px;
}

.rtwc-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.rtwc-cond-cell select,
.rtwc-cond-cell input {
  width: 100%;
}

/* Logs */
.rtwc-logs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.rtwc-clear-btn {
  color: #dc2626 !important;
  border-color: #dc2626 !important;
}

.rtwc-status-code {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
}

.rtwc-status-code--ok  { background: #d1fae5; color: #065f46; }
.rtwc-status-code--err { background: #fee2e2; color: #991b1b; }

/* Log cards */
.rtwc-log-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rtwc-log-card {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
  border-left-width: 4px;
}

.rtwc-log-card--ok  { border-left-color: #10b981; }
.rtwc-log-card--err { border-left-color: #ef4444; }

/* Card header */
.rtwc-log-card-header {
  background: #f8fafc;
  padding: 10px 16px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rtwc-log-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rtwc-log-time {
  font-size: 12px;
  color: #64748b;
  margin-left: auto;
}

.rtwc-log-url {
  font-size: 12px;
  background: #0f172a;
  color: #7dd3fc;
  padding: 4px 10px;
  border-radius: 4px;
  display: block;
  word-break: break-all;
  white-space: pre-wrap;
}

/* Card body: side-by-side panels */
.rtwc-log-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.rtwc-log-panel {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rtwc-log-panel:first-child {
  border-right: 1px solid #e2e8f0;
}

.rtwc-log-panel-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 4px 0;
  border-bottom: 2px solid;
  margin-bottom: 4px;
}

.rtwc-log-panel-title--req { color: #3b82f6; border-color: #3b82f6; }
.rtwc-log-panel-title--ok  { color: #10b981; border-color: #10b981; }
.rtwc-log-panel-title--err { color: #ef4444; border-color: #ef4444; }

.rtwc-log-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rtwc-log-block-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
  font-weight: 600;
}

.rtwc-log-pre {
  margin: 0;
  background: #0f172a;
  color: #e2e8f0;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 220px;
  overflow-y: auto;
  line-height: 1.5;
}

.rtwc-log-empty {
  color: #64748b;
  font-style: italic;
  font-size: 12px;
}

/* Footer */
.rtwc-editor-footer {
  padding: 16px 24px;
  background: #f8f9fa;
  border-top: 1px solid #e5e7eb;
}

/* Required */
.required { color: #dc2626; }
