/* Shared look for every screen: tokens, reset and basic components.
   Logical properties (inline-start/end) keep Arabic right-to-left layouts correct. */

:root {
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-text: #0f766e;
  --brand-strong: #0c5f59;
  --brand-soft: #e2f0ee;
  --brand-softer: #f1f8f7;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #111827;
  --muted: #586172;
  --border: #e3e6eb;
  --border-strong: #c9cfd8;

  --danger: #b42318;
  --danger-soft: #fef3f2;
  --warn: #8a3a0c;
  --warn-soft: #fff8e6;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --info: #1d4f91;
  --info-soft: #eef5fd;

  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.05), 0 2px 8px rgb(16 24 40 / 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", "Geeza Pro", Tahoma, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.45rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.05rem;
  line-height: 1.35;
}

a {
  color: var(--brand-text);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
}

[dir="rtl"] .icon-flip {
  transform: scaleX(-1);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.muted {
  color: var(--muted);
}

.ltr {
  direction: ltr;
  unicode-bidi: isolate;
}

/* Buttons -------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.55rem 1.15rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  color: var(--brand-ink);
}

.btn-primary:not(:disabled):hover {
  background: var(--brand-strong);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink);
}

.btn-secondary:not(:disabled):hover {
  border-color: var(--brand);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-ghost {
  min-height: 44px;
  padding: 0 0.5rem;
  color: var(--brand-text);
}

.btn-ghost:not(:disabled):hover {
  background: var(--brand-softer);
}

.btn-block {
  width: 100%;
}

.btn[aria-busy="true"]::after {
  content: "";
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Cards and alerts --------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.8rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.95rem;
}

.alert .icon {
  margin-top: 0.1em;
}

.alert-info {
  background: var(--info-soft);
  border-color: #cfe1f7;
  color: var(--info);
}

.alert-warn {
  background: var(--warn-soft);
  border-color: #f5dfa8;
  color: var(--warn);
}

.alert-error {
  background: var(--danger-soft);
  border-color: #f8d0cc;
  color: var(--danger);
}

.alert-success {
  background: var(--ok-soft);
  border-color: #b8e6cc;
  color: var(--ok);
}

/* Form fields ----------------------------------------------------------------------- */

.field {
  display: grid;
  gap: 0.35rem;
}

.label {
  font-weight: 600;
  font-size: 0.95rem;
}

.hint {
  color: var(--muted);
  font-size: 0.875rem;
}

.input {
  width: 100%;
  min-height: 48px;
  padding: 0 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  font-size: 16px; /* 16px stops iPhone zooming into the field */
}

.input:focus {
  border-color: var(--brand);
  outline: 3px solid var(--brand-soft);
  outline-offset: 0;
}

.input[aria-invalid="true"] {
  border-color: var(--danger);
}

.field-error {
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 500;
}

/* Loading placeholders ------------------------------------------------------------------ */

.skeleton {
  display: block;
  border-radius: 10px;
  background: linear-gradient(90deg, #eceef2 25%, #f5f6f8 50%, #eceef2 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
