/* =========================================================
   SETTINGS PAGE - Workflow Builder
   Roofing Front Desk
   ========================================================= */

:root {
  --bg: #f3f6fb;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-solid: #ffffff;
  --line: rgba(148, 163, 184, 0.18);
  --line-strong: rgba(148, 163, 184, 0.28);
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --blue: #2563eb;
  --blue-2: #1d4ed8;
  --blue-soft: rgba(37, 99, 235, 0.08);
  --green: #16a34a;
  --green-soft: rgba(22, 163, 74, 0.10);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.10);
  --amber: #d97706;
  --amber-soft: rgba(217, 119, 6, 0.10);
  --shadow-sm: 0 10px 28px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 18px 40px rgba(15, 23, 42, 0.08);
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

/* =========================================================
   PAGE WRAPPER
   ========================================================= */

.main {
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.05), transparent 35%),
    radial-gradient(circle at bottom left, rgba(59, 130, 246, 0.04), transparent 30%);
}

.settings-card {
  margin: 28px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 30px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* =========================================================
   HEADER
   ========================================================= */

.settings-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.settings-card-title {
  font-size: clamp(2rem, 2vw, 2.4rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text);
}

.settings-card-subtitle {
  margin-top: 10px;
  max-width: 860px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--muted);
}

.settings-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(37, 99, 235, 0.08);
  color: var(--blue-2);
  border: 1px solid rgba(37, 99, 235, 0.12);
}

/* =========================================================
   TOOLBAR
   ========================================================= */

.workflow-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: nowrap;
  width: 100%;
  margin-bottom: 20px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 22px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.workflow-toolbar-left,
.workflow-toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.settings-subcard {
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.72);
  border-radius: 22px;
  padding: 18px;
}

.settings-workflow-main-card {
  margin-top: 26px;
}

.settings-workflow-title {
  font-size: clamp(1.8rem, 2.6vw, 2.7rem);
}

.settings-workflow-main-card .workflow-toolbar {
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: auto;
  margin-top: 22px;
  margin-bottom: 0;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
}

.workflow-mini-note {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(241, 245, 249, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.14);
}

/* =========================================================
   SHARED BUTTONS (if not fully covered by global styles)
   ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.18s ease;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--blue-2));
  color: #fff;
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.28);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(37, 99, 235, 0.34);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  border-color: var(--line-strong);
}

.btn-secondary:hover {
  background: #fff;
  border-color: rgba(37, 99, 235, 0.18);
}

.btn-danger-outline {
  background: rgba(220, 38, 38, 0.08);
  color: var(--red);
  border-color: rgba(220, 38, 38, 0.24);
}

.btn-danger-outline:hover {
  background: rgba(220, 38, 38, 0.12);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #fff;
  border-color: transparent;
}

.btn-xs {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
  border-radius: 12px;
}

.hidden-block {
  display: none !important;
}

.settings-number-change-block {
  margin-top: 16px;
}

.settings-number-change-title {
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.settings-number-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-number-status {
  font-size: 13px;
  color: var(--muted);
}

.settings-available-numbers {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.settings-available-number-card {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 12px;
  min-height: 44px;
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
}

.settings-available-number-card.selected {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue-2);
}

/* =========================================================
   STEP STACK
   ========================================================= */

.workflow-sequence-stack {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.workflow-step-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.workflow-step-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: rgba(37, 99, 235, 0.14);
}

.settings-billing-actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.settings-billing-actions .btn-danger-outline {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 13px;
}

.btn-cancel-compact {
  height: 34px !important;
  min-height: 34px !important;
  padding: 0 11px !important;
  border-radius: 10px !important;
  font-size: 12px !important;
  line-height: 1 !important;
}

.cancel-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 20px;
}

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

.cancel-modal-card {
  width: min(560px, 100%);
  background: #fff;
  border-radius: 20px;
  border: 1px solid var(--line);
  padding: 22px;
  box-shadow: var(--shadow-md);
}

.cancel-modal-card-compact {
  width: min(460px, 100%);
  padding: 18px;
}

.cancel-modal-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
}

.cancel-modal-text {
  margin: 10px 0 16px;
  color: var(--muted);
}

.cancel-checkbox {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  color: var(--text);
}

.cancel-modal-actions {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.cancel-modal-actions .btn {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 13px;
}

/* =========================================================
   STEP HEADER
   ========================================================= */

.workflow-step-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.workflow-step-left {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

.workflow-step-number {
  min-width: 64px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.12);
  color: var(--blue-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.workflow-step-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.15;
  color: var(--text);
}

.workflow-step-subtitle {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}

.workflow-step-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* =========================================================
   ENABLED / DISABLED STATUS
   ========================================================= */

.check-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.check-status.enabled {
  background: var(--green-soft);
  color: #166534;
  border-color: rgba(22, 163, 74, 0.12);
}

.check-status.disabled {
  background: var(--red-soft);
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.12);
}

/* =========================================================
   FORM GRID
   ========================================================= */

.settings-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.settings-three-col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

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

#after_hours_fields {
  margin-top: 12px;
}

.coverage-panel {
  margin-top: 14px;
  padding: 0;
  border: 0;
  background: transparent;
}

.settings-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* =========================================================
   INPUTS
   ========================================================= */

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(248, 250, 252, 0.95);
  color: var(--text);
  border-radius: 14px;
  font: inherit;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.input {
  min-height: 48px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
}

.select {
  min-height: 48px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
}

.textarea {
  min-height: 110px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: rgba(37, 99, 235, 0.28);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
  background: #fff;
}

.settings-alert {
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 700;
}

.settings-alert-error {
  background: var(--red-soft);
  color: #991b1b;
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.settings-alert-success {
  background: var(--green-soft);
  color: #166534;
  border: 1px solid rgba(22, 163, 74, 0.2);
}

.settings-alert-muted {
  background: rgba(241, 245, 249, 0.9);
  color: #334155;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.subscription-status-box {
  min-height: 48px;
  width: 100%;
  border-radius: 14px;
  border: 1px solid transparent;
  padding: 0 14px;
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 700;
}

.subscription-status-box.status-active {
  background: var(--green-soft);
  color: #166534;
  border-color: rgba(22, 163, 74, 0.22);
}

.subscription-status-box.status-pending {
  background: var(--amber-soft);
  color: #92400e;
  border-color: rgba(217, 119, 6, 0.25);
}

.subscription-status-box.status-inactive {
  background: var(--red-soft);
  color: #991b1b;
  border-color: rgba(220, 38, 38, 0.22);
}

.workflow-step-textarea {
  min-height: 118px;
}

/* =========================================================
   FOOTER
   ========================================================= */

.workflow-footer {
  margin-top: 26px;
  padding-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.workflow-variable-box {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 22px;
  padding: 16px 18px;
}

.workflow-variable-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 10px;
}

.workflow-variable-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.workflow-variable-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(241, 245, 249, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.16);
  font-size: 12px;
  font-weight: 700;
  color: #334155;
}

.settings-actions-row {
  display: flex;
  justify-content: flex-end;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1100px) {
  .settings-card {
    margin: 20px;
    padding: 20px;
  }

  .workflow-step-top {
    flex-direction: column;
    align-items: stretch;
  }

  .workflow-step-actions {
    justify-content: flex-start;
  }

  .settings-two-col {
    grid-template-columns: 1fr;
  }
  .settings-three-col {
    grid-template-columns: 1fr;
  }

  .workflow-toolbar {
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {
  .settings-card {
    margin: 16px;
    padding: 16px;
    border-radius: 22px;
  }

  .settings-card-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .workflow-toolbar {
    padding: 14px;
    border-radius: 18px;
  }

  .workflow-toolbar-left,
  .workflow-toolbar-right {
    width: 100%;
  }

  .settings-actions-row {
    justify-content: stretch;
  }

  .settings-actions-row .btn {
    width: 100%;
  }

  .workflow-step-card {
    border-radius: 18px;
    padding: 16px;
  }

  .workflow-step-left {
    flex-direction: column;
    gap: 10px;
  }

  .workflow-step-title {
    font-size: 18px;
  }
}
