@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700&display=swap');

:root {
  --bg: #f7f9f8;
  --surface: #ffffff;
  --surface-hover: #f1f5f4;
  --border: #e2e8e7;
  --text: #0f1e1c;
  --text-muted: #5b6b69;
  --primary: #0d9488;
  --primary-hover: #0b7a6f;
  --on-primary: #ffffff;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --ring: #0d9488;
  --shadow: 0 20px 50px -20px rgba(15, 30, 28, 0.25);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0b1210;
    --surface: #121a18;
    --surface-hover: #182220;
    --border: #223330;
    --text: #eaf3f1;
    --text-muted: #93a6a3;
    --primary: #14b8a6;
    --primary-hover: #2dd4bf;
    --on-primary: #052e2b;
    --danger: #f87171;
    --danger-bg: #2a1414;
    --ring: #14b8a6;
    --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme='dark'] {
  --bg: #0b1210;
  --surface: #121a18;
  --surface-hover: #182220;
  --border: #223330;
  --text: #eaf3f1;
  --text-muted: #93a6a3;
  --primary: #14b8a6;
  --primary-hover: #2dd4bf;
  --on-primary: #052e2b;
  --danger: #f87171;
  --danger-bg: #2a1414;
  --ring: #14b8a6;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

/* Component display rules (e.g. `.modal-form label { display: flex }`) are
   author-stylesheet rules and always beat the browser's default `[hidden]`
   styling, regardless of specificity. Without this, any element that both
   has a class-based `display` rule AND gets toggled via `.hidden` stays
   visible. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Vazirmatn', system-ui, sans-serif;
  transition: background 0.2s ease, color 0.2s ease;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 64px calc(24px + env(safe-area-inset-right)) calc(64px + env(safe-area-inset-bottom)) calc(24px + env(safe-area-inset-left));
}

.page-narrow {
  max-width: 480px;
}

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

.page-header h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 700;
}

.page-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
}

.icon {
  width: 20px;
  height: 20px;
  display: block;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.card:hover {
  background: var(--surface-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--primary);
}

.card-icon .icon {
  width: 22px;
  height: 22px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
}

.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.card-placeholder {
  cursor: default;
  opacity: 0.5;
}

.card-placeholder:hover {
  background: var(--surface);
  border-color: var(--border);
  transform: none;
}

/* --- modal --- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 11, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  padding: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text);
}

.modal-title {
  margin: 0 0 20px;
  font-size: 20px;
  font-weight: 700;
}

.method-toggle {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.method-btn {
  flex: 1;
  font: inherit;
  font-size: 13px;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: 8px;
  padding: 9px 0;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.method-btn.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.modal-form input[type='text'],
.modal-form input[type='tel'],
.modal-form input[type='email'],
.modal-form input[type='password'] {
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.modal-form input:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 20%, transparent);
}

.checkbox-field {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}

.checkbox-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.modal-error {
  margin: 0;
  padding: 8px 12px;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 8px;
  font-size: 13px;
}

.modal-submit {
  margin-top: 4px;
  font: inherit;
  font-weight: 600;
  color: var(--on-primary);
  background: var(--primary);
  border: none;
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.modal-submit:hover {
  background: var(--primary-hover);
}

.modal-submit:disabled {
  opacity: 0.6;
  cursor: default;
}

/* --- profile page --- */

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
}

.section-title {
  margin: 0 0 18px;
  font-size: 16px;
  font-weight: 700;
}

.readonly-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.readonly-value {
  font-size: 15px;
  color: var(--text);
  direction: ltr;
  text-align: right;
}

.modal-success {
  margin: 0;
  padding: 8px 12px;
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
  border-radius: 8px;
  font-size: 13px;
}

.logout-link {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--danger);
  background: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.logout-link:hover {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.identifier-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  font: inherit;
  font-size: 13px;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.identifier-chip:hover {
  color: var(--text);
}

.identifier-chip .icon-sm {
  transform: scaleX(-1);
  flex-shrink: 0;
}

#identifier-chip-value {
  direction: ltr;
  unicode-bidi: embed;
}
