:root {
  color-scheme: light;
  --green: #25d366;
  --green-dark: #128c4a;
  --green-deep: #075e54;
  --green-soft: #dcf8c6;
  --text: #020617;
  --text-muted: #475569;
  --border: #cbd5e1;
  --border-soft: #e2e8f0;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

[lang="ar"] body {
  font-family:
    Tahoma, "Noto Sans Arabic", Arial, ui-sans-serif, system-ui, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.page-bg {
  background:
    radial-gradient(circle at top left, rgba(37, 211, 102, 0.2), transparent 30rem),
    radial-gradient(circle at bottom right, rgba(18, 140, 74, 0.16), transparent 26rem),
    #eef2ef;
}

.page {
  display: flex;
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  max-width: 36rem;
  margin: 0 auto;
  padding: 1rem;
  flex-direction: column;
  justify-content: center;
}

.app-card {
  position: relative;
  width: 100%;
  overflow: hidden;
  padding: 1rem;
  border: 1px solid var(--border-soft);
  border-radius: 0.5rem;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.app-card::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background-image:
    linear-gradient(rgba(18, 140, 74, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 140, 74, 0.05) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, black, transparent 70%);
}

.message-bubbles,
.typing-bubble {
  display: none;
}

.app-header,
.link-form,
.result-box,
.app-footer {
  position: relative;
}

.app-header {
  position: relative;
  margin-bottom: 1rem;
  text-align: center;
}

.language-switch {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

.language-switch a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  background: var(--green-soft);
  color: var(--green-deep);
  font-size: 0.8125rem;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    color 150ms ease;
}

.language-switch a:hover {
  border-color: var(--green);
  background: #ecfdf5;
  color: var(--green-deep);
}

.logo {
  display: flex;
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 0.75rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--green);
  color: white;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  outline: 4px solid var(--green-soft);
}

.logo svg {
  width: 2rem;
  height: 2rem;
}

.eyebrow {
  margin: 0;
  color: var(--green-dark);
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0.25rem 0 0;
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1.2;
}

.link-form {
  display: grid;
  gap: 0.75rem;
}

.field {
  display: block;
}

.field-label {
  display: block;
  margin-bottom: 0.5rem;
  color: #1e293b;
  font-size: 0.875rem;
  font-weight: 600;
}

.input-wrap {
  position: relative;
}

.field-icon {
  position: absolute;
  inset-inline-start: 0.75rem;
  top: 50%;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--green-dark);
  pointer-events: none;
  transform: translateY(-50%);
}

.textarea-icon {
  top: 0.75rem;
  transform: none;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: white;
  color: var(--text);
  font: inherit;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition:
    border-color 150ms ease,
    background-color 150ms ease,
    opacity 150ms ease;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

.text-input {
  padding: 0.625rem 1rem;
  padding-inline-start: 2.5rem;
  font-size: 1rem;
}

.message-input {
  min-height: 3.5rem;
  padding: 0.625rem 1rem;
  padding-inline-start: 2.5rem;
  resize: none;
  font-size: 0.875rem;
}

.output-input {
  padding: 0.5rem 0.75rem;
  border-color: var(--border-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 0.875rem;
}

.focus-ring:focus {
  outline: 3px solid rgba(37, 211, 102, 0.28);
  outline-offset: 2px;
}

input:focus,
textarea:focus {
  border-color: var(--green);
}

html[dir="rtl"] input,
html[dir="rtl"] textarea {
  text-align: right;
}

html[dir="rtl"] #phoneInput {
  padding-inline-start: 1rem;
  padding-inline-end: 2.5rem;
}

.error-box {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--danger-border);
  border-radius: 0.375rem;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.875rem;
}

.privacy-note {
  position: relative;
  margin: 0.75rem 0 0;
  padding: 0.7rem 0.85rem;
  padding-inline-start: 2.4rem;
  border: 1px solid #bbf7d0;
  border-radius: 0.5rem;
  background: #f0fdf4;
  color: #14532d;
  font-size: 0.875rem;
  line-height: 1.5;
}

.privacy-note::before {
  position: absolute;
  inset-inline-start: 0.85rem;
  top: 0.8rem;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 999px;
  background: var(--green);
  color: white;
  content: "✓";
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1.15rem;
  text-align: center;
}

.privacy-note strong {
  display: block;
  margin-bottom: 0.125rem;
  color: #052e16;
}

.hidden {
  display: none;
}

.result-box {
  margin-top: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--border-soft);
  border-radius: 0.5rem;
  background: var(--surface-muted);
}

.link-row,
.action-grid {
  display: grid;
  gap: 0.5rem;
}

.link-row {
  grid-template-columns: 1fr;
}

.action-grid {
  grid-template-columns: 1fr;
  margin-top: 0.75rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: white;
  color: #1e293b;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    background-color 150ms ease,
    opacity 150ms ease;
}

.button:hover {
  background: #f1f5f9;
}

.button svg {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}

.button-primary {
  border-color: var(--green);
  background: var(--green);
  color: var(--text);
}

.button-primary:hover {
  background: #20bf5a;
}

.button:disabled,
.button.is-disabled {
  pointer-events: none;
  cursor: not-allowed;
  opacity: 0.5;
}

.app-footer {
  margin-top: 1rem;
  color: #64748b;
  font-size: 0.75rem;
  text-align: center;
}

.app-footer a {
  color: #334155;
  font-weight: 600;
  transition: color 150ms ease;
}

.app-footer a:hover {
  color: var(--green-dark);
}

.chat-dot {
  display: inline-block;
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 999px;
  background: var(--green);
  animation: pulse 1.8s ease-in-out infinite;
}

.chat-dot:nth-child(2) {
  margin: 0 0.25rem;
  animation-delay: 0.15s;
}

.chat-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@media (min-width: 640px) {
  .app-card {
    padding: 1.25rem;
  }

  h1 {
    font-size: 1.875rem;
  }

  .message-bubbles,
  .typing-bubble {
    position: absolute;
    pointer-events: none;
  }

  .message-bubbles {
    inset-inline-start: -0.6rem;
    top: 5.6rem;
    display: grid;
    gap: 0.45rem;
  }

  .message-bubble {
    display: block;
    height: 1.4rem;
    border-radius: 1rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  }

  .message-bubble-primary {
    width: 5.2rem;
    background: var(--green-soft);
  }

  .message-bubble-secondary {
    width: 3.6rem;
    margin-inline-start: 1.1rem;
    background: #ecfdf5;
    outline: 1px solid #d1fae5;
  }

  .typing-bubble {
    inset-inline-end: 1rem;
    top: 7rem;
    display: block;
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    background: white;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
    outline: 1px solid #f1f5f9;
  }

  .link-row {
    grid-template-columns: 1fr auto;
  }

  .action-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
