/* ========================================
   راهورد۳۶۵ - استایل فیت و تمام عرض
   ======================================== */

:root {
  --bg-primary: #0a0e27;
  --bg-secondary: #16213e;
  --bg-card: #1a2332;
  --bg-hover: #1f2937;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --accent: #3b82f6;
  --positive: #10b981;
  --positive-bg: rgba(16, 185, 129, 0.15);
  --negative: #ef4444;
  --negative-bg: rgba(239, 68, 68, 0.15);
  
  --radius-xl: 16px;
  --radius-md: 8px;
  --shadow-card: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0, transparent 50%), 
    radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.1) 0, transparent 50%);
  background-attachment: fixed;
  overflow-x: hidden;
  line-height: 1.5;
}

.container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 100%;
}

main { flex: 1; padding: 0.5rem; width: 100%; }

/* کارت‌ها */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 12px 8px; /* پدینگ افقی کم شد تا جدول جای بیشتری داشته باشد */
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 1rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0 4px 0.5rem 4px;
  border-bottom: 2px solid rgba(59, 130, 246, 0.3);
}

.section-header h2 { font-size: 1.1rem; font-weight: 700; margin: 0; }
.status { font-size: 0.75rem; color: var(--text-tertiary); background: rgba(255,255,255,0.05); padding: 2px 8px; border-radius: 12px; }

/* ========================================
   استایل جدول (فیت کانتینر - بدون اسکرول اضافی)
   ======================================== */
.table-wrapper {
  width: 100%;
  /* اسکرول را نگه می‌داریم محض احتیاط اما با تنظیمات زیر معمولا استفاده نمی‌شود */
  overflow-x: auto; 
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  /* نکته کلیدی برای فیت شدن: */
  table-layout: fixed; 
  border-collapse: collapse;
  font-size: 12px;
}

/* تنظیم عرض ستون‌ها به درصد برای پر کردن کامل فضا */
.data-table th:nth-child(1) { width: 30%; } /* نام */
.data-table th:nth-child(2) { width: 25%; } /* مقدار */
.data-table th:nth-child(3) { width: 25%; } /* تغییر */
.data-table th:nth-child(4) { width: 20%; } /* درصد */

.data-table th {
  padding: 8px 2px;
  text-align: center;
  color: var(--accent);
  font-weight: 600;
  font-size: 11px;
  background: rgba(59, 130, 246, 0.1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table td {
  padding: 12px 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
  text-align: center;
  white-space: nowrap;
  overflow: hidden; /* جلوگیری از بیرون زدن متن */
}

/* تراز بندی محتوا */
.data-table td:first-child { text-align: right; padding-right: 5px; }
.data-table td:last-child { text-align: left; padding-left: 5px; }

/* ردیف‌ها */
.data-table tbody tr { transition: background 0.2s; cursor: pointer; }
.data-table tbody tr:active { background-color: var(--bg-hover); }

/* ========================================
   مدیریت نام‌ها
   ======================================== */
.name-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%; /* پر کردن سلول */
}

.name-text {
  display: block;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis; /* سه نقطه برای متن طولانی */
  white-space: nowrap;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
}

/* تولتیپ برای نمایش اسم کامل */
.name-cell:active::after {
  content: attr(data-tooltip);
  position: absolute;
  top: -30px;
  right: 0;
  background: #000;
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  pointer-events: none;
}

.name-sub { display: none; } 

/* اعداد */
.value-text { font-family: sans-serif; font-weight: 600; font-size: 12px; }

.change-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  border-radius: 6px;
  font-size: 11px;
  font-family: sans-serif;
  font-weight: 700;
  width: 100%; /* پر کردن سلول */
}

.positive { color: var(--positive); }
.positive .change-badge { background: var(--positive-bg); }
.negative { color: var(--negative); }
.negative .change-badge { background: var(--negative-bg); }
.neutral { color: var(--text-tertiary); }

/* ========================================
   جستجو و دکمه‌ها
   ======================================== */
.search-box { margin: 1rem 0; }
.search-input {
  width: 100%; padding: 12px; border-radius: var(--radius-md);
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
  color: white; font-family: inherit; transition: all 0.3s;
}
.search-input:focus { outline: none; border-color: var(--accent); }

.btn-primary, .back-button {
  width: 100%; padding: 12px; border-radius: var(--radius-md); border: none;
  font-weight: 600; cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 8px; margin-bottom: 1rem;
}
.btn-primary { background: linear-gradient(135deg, var(--accent) 0%, #764ba2 100%); color: white; }
.back-button { background: var(--bg-hover); color: var(--text-secondary); justify-content: flex-start; }

/* انیمیشن صفحات */
.view { display: none; opacity: 0; transform: translateX(20px); transition: opacity 0.3s, transform 0.3s; }
.view.active { display: block; opacity: 1; transform: translateX(0); }
.view.sliding-out { transform: translateX(-20px); opacity: 0; }

/* لودینگ */
.loading-overlay {
  position: absolute; inset: 0; background: rgba(26, 26, 46, 0.9);
  display: none; flex-direction: column; align-items: center; justify-content: center;
  z-index: 50; border-radius: var(--radius-xl);
}
.loading-overlay.active { display: flex; }
.spinner {
  width: 40px; height: 40px; border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* فوتر */
footer {
  text-align: center; padding: 1rem; margin-top: auto;
  background: rgba(22, 33, 62, 0.8); color: var(--text-tertiary); font-size: 0.8rem;
}

/* دسکتاپ */
@media (min-width: 768px) {
  .container { max-width: 1200px; margin: 0 auto; padding: 1rem; }
  .card { padding: 2rem; }
  .data-table { font-size: 14px; }
  .data-table th, .data-table td { padding: 16px; }
  .name-text { font-size: 15px; }
  .name-sub { display: block; font-size: 12px; color: var(--text-tertiary); margin-top: 4px; }
  .name-cell:active::after { display: none; }
}

/* فونت - استفاده از CDN معتبرتر */
@font-face {
  font-family: 'Vazirmatn';
  src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@latest/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400; 
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@latest/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700; 
  font-display: swap;
}

/* GB header light theme — bors content */
html[data-theme="light"] body {
  --bg-primary: #eef1f7;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  background-image: none;
}
html[data-theme="light"] .card { border-color: rgba(15,23,42,.08); }
html[data-theme="light"] .search-input { background: #fff; color: #0f172a; border-color: rgba(15,23,42,.12); }
html[data-theme="light"] footer { background: #f8fafc; color: #64748b; }
