@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/Vazirmatn/static/Vazirmatn-Light.ttf') format('truetype');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/Vazirmatn/static/Vazirmatn-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/Vazirmatn/static/Vazirmatn-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/Vazirmatn/static/Vazirmatn-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/Vazirmatn/static/Vazirmatn-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/Vazirmatn/static/Vazirmatn-Black.ttf') format('truetype');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --primary-accent: #f97316;
  --primary-hover: #ea580c;
  --border-color: #334155;
  --font-family: 'Vazirmatn', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gold: #f5c451;
  --gold-dark: #b8860b;
  --radius-lg: 18px;
  --radius-md: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bottom-nav-height: 64px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-primary);
  background-image: radial-gradient(circle at 20% 0%, rgba(249, 115, 22, 0.08), transparent 45%),
                     radial-gradient(circle at 100% 30%, rgba(245, 196, 81, 0.05), transparent 40%);
  color: var(--text-primary);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* هدر اپلیکیشن */
.app-header {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
  padding-top: calc(1rem + var(--safe-top));
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: saturate(180%) blur(12px);
  background-color: rgba(30, 41, 59, 0.88);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.35);
  flex-shrink: 0;
}

.brand-title {
  font-size: clamp(1rem, 4vw, 1.25rem);
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: linear-gradient(90deg, var(--text-primary), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.btn-lang {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.85rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.btn-lang:hover {
  background-color: var(--primary-accent);
  border-color: var(--primary-accent);
  color: #fff;
}

/* تب‌های ناوبری */
.nav-tabs {
  display: flex;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 1rem;
  gap: 0.5rem;
  overflow-x: auto;
}

.nav-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  padding: 0.85rem 1.2rem;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  color: var(--text-primary);
}

.nav-tab.active {
  color: var(--primary-accent);
  border-bottom-color: var(--primary-accent);
}

/* ناوبری پایین صفحه برای موبایل - تجربه اپلیکیشن حرفه‌ای */
@media (max-width: 680px) {
  .nav-tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background-color: rgba(30, 41, 59, 0.96);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: none;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.35);
    padding: 0.4rem 0.5rem calc(0.4rem + var(--safe-bottom));
    gap: 0.25rem;
    justify-content: space-around;
    height: var(--bottom-nav-height);
    overflow-x: visible;
  }

  .nav-tab {
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.68rem;
    padding: 0.4rem 0.5rem;
    border-bottom: none;
    border-radius: 12px;
    flex: 1 1 0;
  }

  .nav-tab.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary-accent), var(--primary-hover));
    box-shadow: 0 4px 10px rgba(249, 115, 22, 0.35);
  }

  .main-content {
    padding-bottom: calc(1.5rem + var(--bottom-nav-height) + var(--safe-bottom));
  }
}

/* بدنه اصلی */
.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

@media (max-width: 480px) {
  .main-content {
    padding: 1rem 0.85rem;
  }
}

.tab-panel {
  display: block;
}

.tab-panel.hidden {
  display: none !important;
}

/* چینش دو ستونه ارزیابی */
.assessment-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
}

@media (max-width: 860px) {
  .assessment-layout {
    grid-template-columns: 1fr;
  }
}

/* کارت‌ها */
.card {
  background-color: var(--bg-secondary);
  background-image: linear-gradient(160deg, rgba(255, 255, 255, 0.03), transparent 60%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.4);
}

@media (max-width: 480px) {
  .card {
    padding: 1.15rem;
    border-radius: var(--radius-md);
  }
}

/* کارت پروفایل مربی */
.profile-card {
  text-align: center;
}

.profile-avatar-container {
  position: relative;
  width: 110px;
  height: 110px;
  margin: 0 auto 1rem;
}

.profile-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--primary-accent);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.15), 0 6px 18px rgba(0, 0, 0, 0.35);
}

.status-indicator {
  position: absolute;
  bottom: 5px;
  right: 5px;
  width: 14px;
  height: 14px;
  background-color: #10b981;
  border: 2px solid var(--bg-secondary);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.7);
}

/* بج طلایی VIP کنار عکس مربی */
.vip-badge {
  position: absolute;
  top: -6px;
  left: -14px;
  background: linear-gradient(135deg, #fff2c4, var(--gold) 45%, var(--gold-dark));
  color: #3a2a00;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 999px;
  box-shadow: 0 3px 10px rgba(184, 134, 11, 0.55), 0 0 0 2px rgba(255, 255, 255, 0.08);
  transform: rotate(-8deg);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.profile-name {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.profile-title {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

/* بج اختصاصی تقدیم */
.profile-dedication-badge {
  display: inline-block;
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.15), rgba(234, 88, 12, 0.25));
  border: 1px solid rgba(249, 115, 22, 0.4);
  color: #fdba74;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 1rem;
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.15);
}

.profile-bio {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

.profile-stats {
  display: flex;
  justify-content: space-around;
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary-accent);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* فرم‌ها */
.panel-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.panel-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary-accent);
}

.gender-options {
  display: flex;
  gap: 1rem;
  margin-top: 0.25rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.9rem;
}

/* دکمه‌ها */
.btn-primary {
  background: linear-gradient(135deg, var(--primary-accent), var(--primary-hover));
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 6px 16px -4px rgba(249, 115, 22, 0.55);
  width: 100%;
}

.btn-primary:hover {
  box-shadow: 0 8px 20px -4px rgba(249, 115, 22, 0.7);
}

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

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background-color: var(--primary-accent);
  border-color: var(--primary-accent);
}

/* نتایج آفلاین */
.results-box {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.metric-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.metric-title {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.metric-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-accent);
}

.metric-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* بخش خروجی هوش مصنوعی */
.ai-section {
  margin-top: 1.5rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.25rem;
}

.ai-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.ai-badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-weight: 600;
}

.ai-badge.loading {
  background-color: rgba(249, 115, 22, 0.15);
  color: #fdba74;
}

.ai-badge.success {
  background-color: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

.ai-badge.error {
  background-color: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

/* رندر تمیز فرمت محتوای AI */
.ai-formatted-content {
  line-height: 1.85;
  color: #e2e8f0;
  font-size: 0.95rem;
}

.ai-formatted-content h1,
.ai-formatted-content h2,
.ai-formatted-content h3 {
  color: #fdba74;
  margin-top: 1.2rem;
  margin-bottom: 0.5rem;
}

.ai-formatted-content strong {
  color: #fb923c;
}

.ai-formatted-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.88rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  overflow: hidden;
}

.ai-formatted-content th,
.ai-formatted-content td {
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 12px;
  text-align: right;
}

.ai-formatted-content th {
  background: rgba(249, 115, 22, 0.15);
  color: #fdba74;
}

.ai-formatted-content tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

/* نوار دکمه کپی */
.copy-action-bar {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.15);
}

.btn-copy-plan {
  background: rgba(249, 115, 22, 0.2);
  border: 1px solid #f97316;
  color: #ffedd5;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-copy-plan:hover {
  background: #f97316;
  color: #fff;
}

/* پنجره مودال نمایش کامل سوابق */
.custom-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  padding: 20px;
}

.custom-modal-content {
  background: #181c24;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  width: 100%;
  max-width: 760px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.btn-close-modal {
  background: #ef4444;
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  float: left;
  font-size: 0.85rem;
}

.btn-close-modal:hover {
  background: #dc2626;
}

/* فوتر */
.app-footer {
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 1.1rem 1rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: auto;
  line-height: 1.7;
}

@media (max-width: 680px) {
  .app-footer {
    margin-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom));
  }
}

.footer-line {
  margin: 0;
}

.footer-line-highlight {
  color: var(--gold);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
}

.footer-line-dim {
  color: var(--text-secondary);
  opacity: 0.7;
  font-size: 0.72rem;
}

/* آیتم‌های تاریخچه */
.history-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.03);
  margin-bottom: 12px;
  padding: 15px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: border-color 0.2s ease;
}

.history-item:hover {
  border-color: rgba(249, 115, 22, 0.35);
}

.history-info {
  min-width: 0;
}

.history-name {
  margin: 0 0 5px 0;
  color: var(--primary-accent);
  font-size: 1rem;
}

.history-meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.history-has-plan {
  color: #10b981;
  margin-right: 8px;
}

.history-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}

.history-btn-view {
  padding: 6px 12px;
}

.history-btn-delete {
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
}

@media (max-width: 480px) {
  .history-item {
    flex-direction: column;
    align-items: stretch;
  }

  .history-actions {
    justify-content: flex-end;
  }
}
