/**
 * پاد — Design System (Phase 2 UI/UX)
 * توکن‌های واحد، کامپوننت‌های پایه، alias برای متغیرهای legacy
 * v20260630
 */

/* ─── Design Tokens ─────────────────────────────────────────────── */
:root {
  /* Brand — Medical Trust */
  --teb-navy-950: #0a1018;
  --teb-navy-900: #0f172a;
  --teb-navy-800: #1e293b;
  --teb-navy-700: #334155;
  --teb-teal-700: #0f766e;
  --teb-teal-600: #0d9488;
  --teb-teal-500: #14b8a6;
  --teb-teal-400: #2dd4bf;
  --teb-green-500: #10b981;
  --teb-green-400: #31df88;
  --teb-sky-500: #0ea5e9;

  /* Semantic */
  --teb-primary: var(--teb-teal-600);
  --teb-primary-dark: var(--teb-teal-700);
  --teb-primary-light: var(--teb-teal-500);
  --teb-accent: var(--teb-green-500);
  --teb-accent-bright: var(--teb-green-400);

  /* Text */
  --teb-text: var(--teb-navy-900);
  --teb-text-muted: #64748b;
  --teb-text-subtle: #94a3b8;
  --teb-text-inverse: #ffffff;

  /* Surfaces */
  --teb-bg: #f8fafc;
  --teb-bg-soft: #f0fdfa;
  --teb-bg-gradient: linear-gradient(165deg, #f0fdfa 0%, #f8fafc 45%, #f1f5f9 100%);
  --teb-bg-page: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 50%, #f0fdf4 100%);
  --teb-surface: #ffffff;
  --teb-surface-glass: rgba(255, 255, 255, 0.92);
  --teb-border: rgba(13, 148, 136, 0.12);
  --teb-border-strong: rgba(13, 148, 136, 0.22);
  --teb-glass-bg: rgba(255, 255, 255, 0.1);
  --teb-glass-border: rgba(255, 255, 255, 0.2);

  /* Status */
  --teb-success: #22c55e;
  --teb-warning: #f59e0b;
  --teb-danger: #ef4444;
  --teb-info: var(--teb-sky-500);

  /* Elevation */
  --teb-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --teb-shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.06);
  --teb-shadow-md: 0 12px 32px rgba(15, 118, 110, 0.08);
  --teb-shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.12);
  --teb-shadow-glow: 0 8px 24px rgba(49, 223, 136, 0.28);
  --teb-shadow-nav: 0 4px 16px rgba(15, 23, 42, 0.22);

  /* Radius */
  --teb-radius-sm: 0.5rem;
  --teb-radius-md: 0.75rem;
  --teb-radius-lg: 1rem;
  --teb-radius-xl: 1.25rem;
  --teb-radius-2xl: 1.5rem;
  --teb-radius-pill: 9999px;

  /* Spacing */
  --teb-space-1: 0.25rem;
  --teb-space-2: 0.5rem;
  --teb-space-3: 0.75rem;
  --teb-space-4: 1rem;
  --teb-space-5: 1.25rem;
  --teb-space-6: 1.5rem;
  --teb-space-8: 2rem;
  --teb-space-10: 2.5rem;
  --teb-space-12: 3rem;

  /* Typography */
  --teb-font: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --teb-font-size-xs: 0.75rem;
  --teb-font-size-sm: 0.875rem;
  --teb-font-size-base: 1rem;
  --teb-font-size-lg: 1.125rem;
  --teb-font-size-xl: 1.25rem;
  --teb-font-size-2xl: 1.5rem;
  --teb-font-size-3xl: 1.875rem;
  --teb-line-height: 1.6;
  --teb-line-height-tight: 1.35;

  /* Motion */
  --teb-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --teb-ease-out: cubic-bezier(0, 0, 0.2, 1);
  --teb-duration-fast: 150ms;
  --teb-duration: 250ms;
  --teb-duration-slow: 400ms;

  /* Gradients */
  --teb-gradient-brand: linear-gradient(135deg, var(--teb-navy-900) 0%, #1e3a5f 50%, var(--teb-teal-500) 100%);
  --teb-gradient-hero: linear-gradient(135deg, var(--teb-navy-900) 0%, var(--teb-teal-700) 55%, var(--teb-green-500) 100%);
  --teb-gradient-cta: linear-gradient(135deg, var(--teb-green-500) 0%, var(--teb-green-400) 100%);
  --teb-gradient-btn: linear-gradient(135deg, var(--teb-teal-500) 0%, var(--teb-green-500) 55%, var(--teb-green-400) 100%);

  /* Legacy aliases — صفحات موجود بدون refactor */
  --primary-color: var(--teb-accent-bright);
  --primary-dark: var(--teb-primary-dark);
  --primary-light: var(--teb-teal-400);
  --primary: var(--teb-primary-dark);
  --secondary-color: var(--teb-navy-700);
  --accent-color: var(--teb-teal-500);
  --accent-teal: var(--teb-teal-500);
  --accent-deep-blue: var(--teb-navy-900);
  --accent-vibrant-green: var(--teb-green-500);
  --success-color: var(--teb-success);
  --warning-color: var(--teb-warning);
  --danger-color: var(--teb-danger);
  --light-bg: var(--teb-bg);
  --dark-bg: var(--teb-navy-900);
  --muted: var(--teb-text-muted);
  --bg: var(--teb-bg);
  --secondary: var(--teb-navy-900);

  /* Doctor dashboard shell */
  --dd-primary: var(--teb-teal-600);
  --dd-primary-dark: var(--teb-teal-700);
  --dd-accent: var(--teb-sky-500);
  --dd-bg: #ecfdf5;
  --dd-surface: var(--teb-surface);
  --dd-text: var(--teb-text);
  --dd-muted: var(--teb-text-muted);
  --dd-radius: var(--teb-radius-lg);
  --dd-shadow: var(--teb-shadow-md);

  /* Auth page */
  --teb-auth-teal: var(--teb-teal-500);
  --teb-auth-green: var(--teb-green-500);
  --teb-auth-emerald: var(--teb-green-400);
  --teb-auth-navy: var(--teb-navy-900);
  --teb-auth-card: var(--teb-surface-glass);
  --teb-auth-border: var(--teb-border-strong);
  --teb-auth-shadow: var(--teb-shadow-lg);
}

/* ─── Base ───────────────────────────────────────────────────────── */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body.teb-app,
.teb-page-shell {
  font-family: var(--teb-font);
  color: var(--teb-text);
  line-height: var(--teb-line-height);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.teb-app {
  background: var(--teb-bg-page);
  background-attachment: fixed;
}

/* ─── Accessibility (WCAG 2.2 AA quick wins) ────────────────────── */
.teb-skip-link {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2000;
  padding: 10px 14px;
  border-radius: var(--teb-radius-pill);
  background: #ffffff;
  color: var(--teb-navy-900);
  border: 2px solid rgba(14, 165, 233, 0.55);
  box-shadow: var(--teb-shadow-sm);
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform var(--teb-duration-fast) var(--teb-ease);
}

.teb-skip-link:focus,
.teb-skip-link:focus-visible {
  transform: translateY(0);
}

/* Focus ring — واضح و یکسان */
:where(a, button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 3px solid rgba(14, 165, 233, 0.65);
  outline-offset: 2px;
}

/* اگر عنصر خودش shadow-focus دارد، هنوز outline برای کیبورد حفظ می‌شود */
:where(.btn, .form-control, .form-select):focus {
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  html:focus-within {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── Typography ─────────────────────────────────────────────────── */
.teb-display {
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: var(--teb-line-height-tight);
  color: var(--teb-text);
}

.teb-heading-1 { font-size: clamp(1.5rem, 3vw, var(--teb-font-size-3xl)); font-weight: 800; }
.teb-heading-2 { font-size: clamp(1.25rem, 2.5vw, var(--teb-font-size-2xl)); font-weight: 700; }
.teb-heading-3 { font-size: var(--teb-font-size-xl); font-weight: 700; }

.teb-text-muted { color: var(--teb-text-muted) !important; }
.teb-text-subtle { color: var(--teb-text-subtle) !important; }

/* ─── Navbar (site header) ───────────────────────────────────────── */
.teb-site-navbar,
.site-navbar {
  background: var(--teb-gradient-brand) !important;
  box-shadow: var(--teb-shadow-nav);
  z-index: 1030;
  backdrop-filter: blur(8px);
}

.teb-site-navbar .navbar-brand,
.site-navbar .navbar-brand {
  font-weight: 700;
  color: var(--teb-text-inverse) !important;
  letter-spacing: -0.01em;
}

.teb-site-navbar .nav-link,
.site-navbar .nav-link {
  color: rgba(255, 255, 255, 0.92) !important;
  font-weight: 500;
  transition: color var(--teb-duration-fast) var(--teb-ease);
}

.teb-site-navbar .nav-link:hover,
.teb-site-navbar .nav-link:focus,
.site-navbar .nav-link:hover,
.site-navbar .nav-link:focus {
  color: #fff !important;
}

.teb-site-navbar .btn-light,
.site-navbar .btn-light {
  background: rgba(255, 255, 255, 0.95);
  border: none;
  font-weight: 600;
  border-radius: var(--teb-radius-pill);
  transition: transform var(--teb-duration-fast) var(--teb-ease), box-shadow var(--teb-duration-fast) var(--teb-ease);
}

.teb-site-navbar .btn-light:hover,
.site-navbar .btn-light:hover {
  transform: translateY(-1px);
  box-shadow: var(--teb-shadow-sm);
}

.teb-site-navbar .btn-outline-light,
.site-navbar .btn-outline-light {
  border-radius: var(--teb-radius-pill);
  font-weight: 600;
}

/* ─── Cards ─────────────────────────────────────────────────────── */
.teb-card {
  background: var(--teb-surface);
  border: 1px solid var(--teb-border);
  border-radius: var(--teb-radius-xl);
  box-shadow: var(--teb-shadow-sm);
  padding: var(--teb-space-5);
  transition: border-color var(--teb-duration) var(--teb-ease),
    box-shadow var(--teb-duration) var(--teb-ease),
    transform var(--teb-duration) var(--teb-ease);
}

.teb-card:hover {
  border-color: var(--teb-border-strong);
  box-shadow: var(--teb-shadow-md);
}

.teb-card-interactive:hover {
  transform: translateY(-3px);
}

.teb-card-soft {
  background: var(--teb-surface);
  border: 1px solid #e2e8f0;
  border-radius: var(--teb-radius-2xl);
  padding: var(--teb-space-5);
  box-shadow: var(--teb-shadow-sm);
  transition: transform var(--teb-duration) var(--teb-ease), box-shadow var(--teb-duration) var(--teb-ease), border-color var(--teb-duration) var(--teb-ease);
}

.teb-card-soft:hover {
  transform: translateY(-4px);
  border-color: rgba(20, 184, 166, 0.35);
  box-shadow: 0 14px 30px rgba(20, 184, 166, 0.12);
}

/* ─── Buttons ───────────────────────────────────────────────────── */
.teb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--teb-space-2);
  font-weight: 700;
  border-radius: var(--teb-radius-pill);
  padding: 0.6rem 1.25rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--teb-duration-fast) var(--teb-ease),
    box-shadow var(--teb-duration-fast) var(--teb-ease),
    background var(--teb-duration-fast) var(--teb-ease);
}

.teb-btn-primary {
  background: var(--teb-gradient-cta);
  color: var(--teb-navy-900);
  box-shadow: var(--teb-shadow-glow);
}

.teb-btn-primary:hover,
.teb-btn-primary:focus {
  color: var(--teb-navy-900);
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(49, 223, 136, 0.4);
}

.teb-btn-secondary {
  background: var(--teb-surface);
  color: var(--teb-primary-dark);
  border: 2px solid var(--teb-border-strong);
}

.teb-btn-secondary:hover {
  background: var(--teb-bg-soft);
  color: var(--teb-primary-dark);
}

.teb-btn-ghost {
  background: transparent;
  color: var(--teb-primary);
  border: 1px solid transparent;
}

.teb-btn-ghost:hover {
  background: rgba(13, 148, 136, 0.08);
}

/* ─── Sections & Hero ───────────────────────────────────────────── */
.teb-section {
  padding: var(--teb-space-12) 0;
}

.teb-hero {
  background: var(--teb-gradient-hero);
  color: var(--teb-text-inverse);
  padding: 3.25rem 0 1.5rem;
}

.teb-hero .teb-chip {
  display: inline-block;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 4px 12px;
  border-radius: var(--teb-radius-pill);
  font-size: var(--teb-font-size-xs);
  font-weight: 600;
  margin-bottom: var(--teb-space-2);
}

/* ─── Footer ────────────────────────────────────────────────────── */
.teb-footer {
  background: linear-gradient(180deg, var(--teb-teal-700) 0%, var(--teb-teal-600) 100%);
  color: var(--teb-text-inverse);
  padding: var(--teb-space-10) 0 var(--teb-space-8);
  margin-top: var(--teb-space-10);
}

.teb-footer-logo {
  font-size: var(--teb-font-size-2xl);
  font-weight: 700;
  margin-bottom: var(--teb-space-4);
  display: flex;
  align-items: center;
  gap: var(--teb-space-2);
}

.teb-footer-desc {
  color: rgba(255, 255, 255, 0.88);
  line-height: var(--teb-line-height);
  margin-bottom: var(--teb-space-6);
}

.teb-footer-title {
  color: #fff;
  font-weight: 600;
  margin-bottom: var(--teb-space-5);
}

.teb-footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.teb-footer-links li {
  margin-bottom: var(--teb-space-2);
}

.teb-footer-links a {
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  transition: color var(--teb-duration-fast) var(--teb-ease);
}

.teb-footer-links a:hover {
  color: #fff;
}

.teb-footer-social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  margin-left: 8px;
  transition: background var(--teb-duration-fast) var(--teb-ease), transform var(--teb-duration-fast) var(--teb-ease);
}

.teb-footer-social a:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(-2px);
}

.teb-footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  padding-top: var(--teb-space-5);
  margin-top: var(--teb-space-8);
  text-align: center;
  color: rgba(255, 255, 255, 0.82);
  font-size: var(--teb-font-size-sm);
}

/* ─── Forms (Bootstrap polish) ──────────────────────────────────── */
.teb-app .form-control,
.teb-app .form-select,
.teb-page-shell .form-control,
.teb-page-shell .form-select {
  border-radius: var(--teb-radius-md);
  border-color: #e2e8f0;
  transition: border-color var(--teb-duration-fast) var(--teb-ease), box-shadow var(--teb-duration-fast) var(--teb-ease);
}

.teb-app .form-control:focus,
.teb-app .form-select:focus,
.teb-page-shell .form-control:focus,
.teb-page-shell .form-select:focus {
  border-color: var(--teb-teal-500);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

/* ─── Badges & Status ───────────────────────────────────────────── */
.teb-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--teb-radius-pill);
  font-size: var(--teb-font-size-xs);
  font-weight: 600;
}

.teb-badge-success { background: #dcfce7; color: #166534; }
.teb-badge-warning { background: #fef3c7; color: #92400e; }
.teb-badge-danger { background: #fee2e2; color: #991b1b; }
.teb-badge-info { background: #e0f2fe; color: #075985; }

/* ─── Loading skeleton ──────────────────────────────────────────── */
@keyframes teb-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.teb-skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: teb-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--teb-radius-md);
}

/* ─── Motion utilities ──────────────────────────────────────────── */
@keyframes teb-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.teb-animate-in {
  animation: teb-fade-in var(--teb-duration-slow) var(--teb-ease-out) both;
}

.teb-stagger-1 { animation-delay: 50ms; }
.teb-stagger-2 { animation-delay: 100ms; }
.teb-stagger-3 { animation-delay: 150ms; }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── Page content rhythm ───────────────────────────────────────── */
.teb-container-narrow {
  max-width: 720px;
  margin-inline: auto;
}

.teb-section-title {
  font-weight: 800;
  margin-bottom: var(--teb-space-2);
  color: var(--teb-text);
}

.teb-section-subtitle {
  color: var(--teb-text-muted);
  margin-bottom: var(--teb-space-6);
}
