/*
 * Application styles. The UI intentionally mirrors Shopify Admin / Polaris
 * primitives without pulling in a frontend framework.
 */

:root {
  color-scheme: light;
  --p-bg: #f1f1f1;
  --p-surface: #ffffff;
  --p-surface-subdued: #f7f7f7;
  --p-text: #202223;
  --p-text-subdued: #616161;
  --p-text-disabled: #8a8a8a;
  --p-border: #d4d4d4;
  --p-border-subdued: #ebebeb;
  --p-primary: #008060;
  --p-primary-hover: #006e52;
  --p-critical: #bf0711;
  --p-critical-bg: #fff4f4;
  --p-success: #008060;
  --p-success-bg: #e4f7ed;
  --p-warning: #b98900;
  --p-warning-bg: #fff8e5;
  --p-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
}

.legal-shell {
  width: min(880px, calc(100% - 40px));
  margin: 0 auto;
  padding: 56px 0 80px;
}

.legal-header {
  margin-bottom: 24px;
}

.legal-header h1 {
  margin: 6px 0 10px;
  font-size: clamp(2rem, 6vw, 3.25rem);
  line-height: 1.08;
}

.legal-header p,
.legal-content p,
.legal-content li {
  color: #5c5f62;
  line-height: 1.65;
}

.legal-kicker {
  color: #008060 !important;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.legal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 16px 0;
  border-block: 1px solid #e1e3e5;
}

.legal-nav a,
.legal-content a {
  color: #006e52;
  font-weight: 600;
}

.legal-content {
  padding-top: 24px;
}

.legal-content h2 {
  margin: 32px 0 8px;
  font-size: 1.3rem;
}

.legal-content li + li {
  margin-top: 8px;
}

.legal-content code {
  padding: 2px 5px;
  border-radius: 4px;
  background: #f1f2f3;
  color: #202223;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--p-bg);
  color: var(--p-text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  margin: 0;
}

.embedded-app {
  min-height: 100vh;
}

.app-shell {
  margin: 0 auto;
  max-width: 1100px;
  padding: 24px;
}

.page {
  display: grid;
  gap: 16px;
}

.page-header {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.page-title {
  display: grid;
  gap: 4px;
}

.page-title h1 {
  font-size: 24px;
  letter-spacing: 0;
  line-height: 1.25;
  margin: 0;
}

.page-title p,
.subdued {
  color: var(--p-text-subdued);
  margin: 0;
}

.page-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.tabs {
  align-items: center;
  border-bottom: 1px solid var(--p-border);
  display: flex;
  gap: 4px;
}

.tab {
  border-bottom: 3px solid transparent;
  color: var(--p-text-subdued);
  display: inline-flex;
  font-weight: 650;
  padding: 10px 12px 9px;
  text-decoration: none;
}

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

.tab-active {
  border-bottom-color: var(--p-text);
  color: var(--p-text);
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-two {
  grid-template-columns: minmax(0, 1fr) 320px;
}

.card {
  background: var(--p-surface);
  border: 1px solid var(--p-border-subdued);
  border-radius: 8px;
  box-shadow: var(--p-shadow);
  overflow: hidden;
}

.card-header,
.card-section {
  padding: 16px;
}

.card-header {
  border-bottom: 1px solid var(--p-border-subdued);
  display: grid;
  gap: 4px;
}

.card-header h2,
.card-section h2,
.plan-card h2 {
  font-size: 15px;
  line-height: 1.35;
  margin: 0;
}

.card-section + .card-section {
  border-top: 1px solid var(--p-border-subdued);
}

.form-grid {
  display: grid;
  gap: 16px;
}

.merchant-provider-settings[hidden] {
  display: none;
}

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

.delivery-option {
  align-items: flex-start;
  background: var(--p-surface-subdued);
  border: 1px solid var(--p-border);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 14px;
}

label.delivery-option {
  cursor: pointer;
}

.delivery-option-selected {
  background: var(--p-success-bg);
  border-color: var(--p-success);
}

.delivery-option-disabled {
  color: var(--p-text-disabled);
  cursor: not-allowed;
}

.delivery-option-title {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.delivery-option input[type="radio"] {
  height: 18px;
  min-height: 18px;
  width: 18px;
}

.provider-fields {
  background: var(--p-surface-subdued);
  border: 1px solid var(--p-border-subdued);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.provider-fields[hidden] {
  display: none;
}

.provider-fields h3 {
  font-size: 14px;
  margin: 0;
}

.test-sms-panel {
  align-items: end;
  border-top: 1px solid var(--p-border-subdued);
  display: grid;
  gap: 12px;
  grid-template-areas:
    "phone action"
    "help  .";
  grid-template-columns: minmax(0, 1fr) auto;
  padding-top: 16px;
}

.test-sms-panel > .field {
  grid-area: phone;
}

.test-sms-panel > .field-help {
  grid-area: help;
}

.test-sms-panel > input[type="submit"] {
  grid-area: action;
}

.field {
  display: grid;
  gap: 6px;
}

.field-inline {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.field label,
.field-label {
  color: var(--p-text);
  font-weight: 650;
}

.field-help {
  color: var(--p-text-subdued);
  font-size: 13px;
  margin: 0;
}

.credential-status {
  align-items: center;
  color: var(--p-text-subdued);
  display: flex;
  font-size: 13px;
  gap: 8px;
  margin: 0;
}

input,
select,
textarea {
  background: var(--p-surface);
  border: 1px solid #8a8a8a;
  border-radius: 6px;
  color: var(--p-text);
  font: inherit;
  min-height: 36px;
  padding: 7px 11px;
  width: 100%;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #005bd3;
  box-shadow: 0 0 0 1px #005bd3;
  outline: 0;
}

input[type="checkbox"] {
  accent-color: var(--p-primary);
  height: 18px;
  min-height: 18px;
  width: 18px;
}

.switch-label {
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 auto;
}

.switch-label input[type="checkbox"] {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.switch {
  background: #8a8a8a;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  display: inline-flex;
  height: 24px;
  position: relative;
  transition: background 120ms ease;
  width: 44px;
}

.switch::after {
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.24);
  content: "";
  height: 20px;
  left: 2px;
  position: absolute;
  top: 2px;
  transition: transform 120ms ease;
  width: 20px;
}

.switch-input:checked + .switch {
  background: var(--p-primary);
}

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

.switch-input:focus-visible + .switch {
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #005bd3;
}

.button,
input[type="submit"],
button,
.button_to button {
  align-items: center;
  background: var(--p-surface);
  border: 1px solid #8a8a8a;
  border-radius: 6px;
  box-shadow: var(--p-shadow);
  color: var(--p-text);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 650;
  justify-content: center;
  min-height: 36px;
  padding: 7px 14px;
  text-decoration: none;
  width: auto;
}

.button:hover,
button:hover,
.button_to button:hover {
  background: var(--p-surface-subdued);
}

.button-primary,
input[type="submit"] {
  background: var(--p-primary);
  border-color: var(--p-primary);
  color: #ffffff;
}

.button-primary:hover,
input[type="submit"]:hover {
  background: var(--p-primary-hover);
}

.test-delivery-button {
  gap: 8px;
}

.button-spinner {
  animation: button-spinner-rotate 0.8s linear infinite;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: none;
  height: 16px;
  width: 16px;
}

.button-loading .button-spinner {
  display: inline-block;
}

@keyframes button-spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

button:disabled,
.button_to button:disabled {
  background: #f1f1f1;
  border-color: var(--p-border);
  color: var(--p-text-disabled);
  cursor: default;
}

.button_to {
  margin: 0;
}

.badge {
  align-items: center;
  background: #ebebeb;
  border-radius: 999px;
  color: var(--p-text);
  display: inline-flex;
  font-size: 12px;
  font-weight: 650;
  min-height: 22px;
  padding: 2px 8px;
}

.badge-success {
  background: var(--p-success-bg);
  color: var(--p-success);
}

.badge-warning {
  background: var(--p-warning-bg);
  color: var(--p-warning);
}

.badge-critical {
  background: var(--p-critical-bg);
  color: var(--p-critical);
}

.badge-neutral {
  background: var(--p-surface-subdued);
  color: var(--p-text-subdued);
}

.banner {
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 12px 14px;
}

.banner-success {
  background: var(--p-success-bg);
  color: var(--p-success);
}

.banner-critical {
  background: var(--p-critical-bg);
  color: var(--p-critical);
}

.banner p,
.banner ul {
  margin: 0;
}

.banner ul {
  padding-left: 20px;
}

.summary-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.summary-row {
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.summary-row dt {
  color: var(--p-text-subdued);
}

.summary-row dd {
  font-weight: 650;
  margin: 0;
  text-align: right;
}

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

.plan-card {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.plan-card-selected {
  border-color: var(--p-primary);
  box-shadow: inset 0 0 0 1px var(--p-primary);
}

.plan-card-header {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.plan-price {
  font-size: 28px;
  font-weight: 750;
  margin: 8px 0 0;
}

.plan-price span {
  color: var(--p-text-subdued);
  font-size: 13px;
  font-weight: 650;
}

.feature-list {
  color: var(--p-text-subdued);
  margin: 0;
  padding-left: 20px;
}

.feature-list li + li {
  margin-top: 8px;
}

.setup-list {
  color: var(--p-text-subdued);
  margin: 0;
  padding-left: 20px;
}

.setup-list li + li {
  margin-top: 8px;
}

.setup-action {
  align-items: center;
  display: flex;
  justify-content: flex-start;
}

.usage-meter {
  background: var(--p-border-subdued);
  border-radius: 999px;
  height: 8px;
  margin-top: 14px;
  overflow: hidden;
}

.usage-meter span {
  background: var(--p-primary);
  display: block;
  height: 100%;
}

.usage-empty {
  margin-top: 14px;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  border-collapse: collapse;
  width: 100%;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--p-border-subdued);
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  color: var(--p-text-subdued);
  font-size: 12px;
  font-weight: 650;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.empty-state {
  color: var(--p-text-subdued);
  text-align: center;
}

.form-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.public-verify-shell {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.public-verify-card {
  background: var(--p-surface);
  border: 1px solid var(--p-border-subdued);
  border-radius: 8px;
  box-shadow: var(--p-shadow);
  display: grid;
  gap: 20px;
  max-width: 460px;
  padding: 24px;
  width: 100%;
}

.public-verify-header {
  display: grid;
  gap: 6px;
}

.public-verify-header h1 {
  font-size: 24px;
  line-height: 1.25;
  margin: 0;
}

.public-verify-header p,
.public-verify-meta {
  color: var(--p-text-subdued);
  margin: 0;
}

.public-verify-kicker {
  color: var(--p-text-subdued);
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
}

.public-verify-form {
  display: grid;
  gap: 16px;
}

.otp-input {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: 0;
  text-align: center;
}

.public-verify-submit {
  justify-content: center;
  margin-top: 8px;
  width: 100%;
}

@media (max-width: 860px) {
  .app-shell {
    padding: 16px;
  }

  .page-header,
  .field-inline {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid-two,
  .plan-grid,
  .delivery-options {
    grid-template-columns: 1fr;
  }

  .test-sms-panel {
    grid-template-areas:
      "phone"
      "help"
      "action";
    grid-template-columns: 1fr;
  }

  .page-actions {
    justify-content: flex-start;
  }
}
