/* Auth Gateway - no CDN (air-gapped). Uses system fonts; add Vazirmatn to static/fonts/ for Persian. */

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

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Vazirmatn", sans-serif;
  background-color: #f1f5f9;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* Font stack: system fonts (air-gapped). Vazirmatn in static/fonts/ for Persian. */
.auth-container,
.auth-container *,
.auth-card,
.auth-card * {
  font-family: 'Vazirmatn', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.auth-container {
  width: 100%;
  max-width: 28rem;
  padding: 0 1rem;
}

.auth-card {
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  padding: 1.5rem;
  transition: box-shadow 0.2s;
}

@media (min-width: 480px) {
  .auth-card {
    padding: 2rem;
  }
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 0.5rem 0;
}

.auth-subtitle {
  color: #475569;
  margin: 0 0 1.5rem 0;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-form label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #334155;
  margin-bottom: 0.25rem;
}

.auth-form input {
  width: 100%;
  padding: 0.625rem 1rem;
  min-height: 48px;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  font-size: 16px; /* prevents zoom on iOS */
}

@media (min-width: 480px) {
  .auth-form input {
    min-height: 44px;
  }
}

.auth-form input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

.auth-form button {
  width: 100%;
  padding: 0.625rem 1rem;
  background: #2563eb;
  color: white;
  font-weight: 500;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.2s;
}

.auth-form button:hover {
  background: #1d4ed8;
}

.auth-footer {
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: #64748b;
  text-align: center;
}

.auth-footer a {
  color: #2563eb;
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.auth-brand {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: #64748b;
  text-align: center;
}

.hidden,
.auth-form .hidden {
  display: none;
}

.auth-error {
  color: #dc2626;
}

/* Registration - mobile-first buttons */
.reg-btn-primary {
  width: 100%;
  padding: 0.75rem 1.25rem;
  min-height: 48px;
  background: #2563eb;
  color: white;
  font-weight: 600;
  font-size: 1rem;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.reg-btn-primary:hover {
  background: #1d4ed8;
}

.reg-btn-primary:active {
  transform: scale(0.98);
}

.reg-btn-secondary {
  width: 100%;
  padding: 0.625rem 1rem;
  min-height: 44px;
  background: #f1f5f9;
  color: #475569;
  font-weight: 500;
  font-size: 0.9375rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.reg-btn-secondary:hover:not(:disabled) {
  background: #e2e8f0;
}

.reg-btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.reg-switch-option {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
}

/* Registration - screen transitions (only one visible at a time) */
.reg-screen {
  display: none !important;
}

.reg-screen.active {
  display: block !important;
  animation: reg-fade-in 0.3s ease;
}

@keyframes reg-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Phone input with country code */
.reg-phone-row {
  display: flex;
  gap: 0.5rem;
}

.reg-phone-row .reg-country {
  flex: 0 0 7rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  font-size: 1rem;
}

.reg-phone-row .reg-phone-input {
  flex: 1;
  padding: 0.5rem 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  font-size: 1rem;
}

.reg-phone-row .reg-phone-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

/* OTP / backup code: همیشه چپ‌به‌راست حتی در صفحهٔ RTL */
.reg-otp-wrap {
  display: flex;
  flex-direction: row;
  direction: ltr;
  justify-content: center;
  gap: 0.5rem;
  margin: 1rem 0;
  unicode-bidi: isolate;
}

.reg-otp-digit {
  width: 2.5rem;
  height: 2.75rem;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  border: 2px solid #cbd5e1;
  border-radius: 0.5rem;
  transition: border-color 0.2s;
}

.reg-otp-digit:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
}

.reg-otp-digit.filled {
  border-color: #22c55e;
}

@media (max-width: 380px) {
  .reg-otp-digit {
    width: 2.25rem;
    height: 2.5rem;
    font-size: 1rem;
  }
}

.reg-otp-timer {
  font-size: 0.875rem;
  color: #64748b;
  margin-top: 0.5rem;
}

.reg-otp-timer.expired {
  color: #94a3b8;
}

/* Loading / disabled */
.reg-btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.8;
}

.reg-btn-loading::after {
  content: "";
  position: absolute;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255,255,255,0.5);
  border-top-color: white;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  margin: -0.5rem 0 0 -0.5rem;
  animation: reg-spin 0.6s linear infinite;
}

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

/* Success state */
.reg-success-icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1rem;
  background: #22c55e;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.5rem;
}

.reg-success-title {
  color: #16a34a;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Inline validation */
.reg-input-error {
  border-color: #dc2626 !important;
}

.reg-input-error:focus {
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.3);
}

.reg-field-error {
  font-size: 0.75rem;
  color: #dc2626;
  margin-top: 0.25rem;
}

/* Link-style button or anchor (secondary option) */
.reg-link-btn {
  background: none;
  border: none;
  color: #64748b;
  font-size: 0.875rem;
  cursor: pointer;
  padding: 0.25rem 0;
  text-decoration: none;
  transition: color 0.2s;
}

.reg-link-btn:hover {
  color: #2563eb;
  text-decoration: underline;
}

a.reg-link-btn {
  display: inline-block;
}

/* Verified badge */
.reg-verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: #16a34a;
  margin-bottom: 1rem;
}

/* Recovery page */
.auth-list {
  list-style: disc;
  list-style-position: inside;
  color: #475569;
  margin: 0 0 1.5rem 0;
  padding: 0;
}

.auth-list li {
  margin-bottom: 0.5rem;
}

.auth-back {
  display: block;
  width: 100%;
  padding: 0.625rem 1rem;
  background: #e2e8f0;
  color: #1e293b;
  font-weight: 500;
  border-radius: 0.5rem;
  text-align: center;
  text-decoration: none;
  transition: background 0.2s;
}

.auth-back:hover {
  background: #cbd5e1;
}

/* Admin layout - Modern redesign */
.admin-body {
  margin: 0 !important;
  padding: 0 !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  background-attachment: fixed;
  min-height: 100vh;
  display: block !important;
  flex-direction: unset !important;
  align-items: unset !important;
  justify-content: unset !important;
}

.admin-nav {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  height: auto !important;
  min-height: 60px !important;
  background: rgba(30, 41, 59, 0.95) !important;
  backdrop-filter: blur(10px);
  color: white;
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 1000;
  display: block !important;
  float: none !important;
  clear: both !important;
}

.admin-nav-inner {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  justify-content: space-between;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 2rem;
  width: 100%;
}

.admin-nav .brand {
  color: white;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-nav .brand::before {
  content: "🔐";
  font-size: 1.5rem;
}

.admin-nav .links {
  display: flex !important;
  flex-direction: row !important;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-nav .links a {
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  padding: 0.625rem 1rem;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
  position: relative;
}

.admin-nav .links a:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.admin-nav .links a.active {
  color: white;
  background: rgba(255, 255, 255, 0.15);
  font-weight: 600;
}

.admin-main {
  max-width: 1400px;
  margin: 0 auto !important;
  margin-top: 70px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding: 1.5rem;
  width: 100%;
  display: block !important;
  float: none !important;
  clear: both !important;
}

/* Admin content blocks */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.admin-table th,
.admin-table td {
  padding: 1rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.admin-table th {
  background: linear-gradient(to bottom, #f8fafc, #f1f5f9);
  font-weight: 600;
  color: #1e293b;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-table tbody tr {
  transition: background-color 0.15s ease;
}

.admin-table tbody tr:hover {
  background-color: #f8fafc;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-card {
  background: white;
  border-radius: 0.5rem;
  padding: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  margin-bottom: 1rem;
  transition: all 0.2s ease;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.admin-card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  transform: translateY(-2px);
}

.admin-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.admin-card-link:hover {
  text-decoration: none;
}

.admin-card-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
  display: block;
  line-height: 1;
}

.admin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.5rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.admin-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.admin-btn:active {
  transform: translateY(0);
}

.admin-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.admin-form-group {
  margin-bottom: 1.5rem;
}

.admin-form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: #334155;
  letter-spacing: 0.025em;
}

.admin-form-group input,
.admin-form-group select,
.admin-form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  transition: all 0.2s ease;
  background: white;
  color: #1e293b;
}

.admin-form-group input:focus,
.admin-form-group select:focus,
.admin-form-group textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.admin-form-group textarea {
  resize: vertical;
  min-height: 100px;
  font-family: inherit;
}

.admin-form-group .hint {
  font-size: 0.8125rem;
  color: #64748b;
  margin-top: 0.5rem;
  line-height: 1.5;
}

.admin-form-group input[type="checkbox"] {
  width: auto;
  margin-right: 0.5rem;
  cursor: pointer;
}

.admin-form-group label[for] {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  font-weight: 500;
}

.admin-h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: white;
  margin: 0 0 1.5rem 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  letter-spacing: -0.025em;
}

.admin-h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 0.5rem 0;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.admin-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 768px) {
  .admin-grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  .admin-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
  .admin-grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

.admin-link {
  color: #667eea;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.admin-link:hover {
  color: #764ba2;
  text-decoration: underline;
}

.admin-inline-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.5rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 0.5rem;
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 600;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  gap: 0.5rem;
}

.admin-inline-btn::before {
  content: "+";
  font-size: 1.25rem;
  line-height: 1;
}

.admin-inline-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  color: white;
  text-decoration: none;
}

.admin-amber-btn {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.admin-amber-btn:hover {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}

.admin-danger-btn {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.admin-danger-btn:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

.admin-flex {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-mb-6 {
  margin-bottom: 1.5rem;
}

.admin-text-muted {
  color: #475569;
  font-size: 0.8125rem;
  line-height: 1.5;
  margin: 0;
}

.admin-code-block {
  padding: 1rem 1.25rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  font-family: ui-monospace, "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, monospace;
  font-size: 0.875rem;
  word-break: break-all;
  line-height: 1.6;
  color: #1e293b;
}

.admin-empty {
  padding: 3rem 2rem;
  text-align: center;
  color: #64748b;
  font-size: 0.9375rem;
}

.admin-empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.admin-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-badge-primary {
  background: #dbeafe;
  color: #1e40af;
}

.admin-badge-success {
  background: #d1fae5;
  color: #065f46;
}

.admin-badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.admin-badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.admin-alert {
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  margin-bottom: 1.5rem;
  border-left: 4px solid;
}

.admin-alert-success {
  background: #d1fae5;
  border-color: #10b981;
  color: #065f46;
}

.admin-alert-error {
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
}

.admin-alert-warning {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
}

.admin-alert-info {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1e40af;
}

/* Admin checkbox group */
.admin-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 0.5rem;
  border: 1px solid #e2e8f0;
}

.admin-checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.375rem;
  transition: background-color 0.15s ease;
}

.admin-checkbox-item:hover {
  background: rgba(102, 126, 234, 0.05);
}

.admin-checkbox-item input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
  accent-color: #667eea;
  margin: 0;
}

.admin-checkbox-item span {
  font-size: 0.9375rem;
  color: #334155;
  user-select: none;
}

/* Admin order list (sortable) */
.admin-order-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 0.5rem;
  border: 1px solid #e2e8f0;
  min-height: 150px;
}

.admin-order-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  cursor: move;
  transition: all 0.2s ease;
}

.admin-order-item:hover {
  border-color: #667eea;
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.1);
}

.admin-order-item.admin-order-item-hidden {
  display: none;
}

.admin-order-handle {
  font-size: 1.25rem;
  color: #94a3b8;
  cursor: grab;
  user-select: none;
}

.admin-order-handle:active {
  cursor: grabbing;
}

.admin-order-item span:not(.admin-order-handle) {
  flex: 1;
  font-size: 0.9375rem;
  color: #334155;
}
