/* ---------- تنظیمات پایه ---------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html{
  scroll-behavior: smooth;
}

body {
  font-family: system-ui, sans-serif;
  background-color: #f5f5f5;
  color: #222;
  line-height: 1.6;
}

/* ---------- هدر ---------- */
.top-header{
  padding:1rem 4rem;
  background:linear-gradient(45deg, #001421, #00254b);
  color: white;
  display: flex;
  justify-content: space-between;
  text-align: center;
  align-items: center;
}
.top-header h2{
  font-size:1.5rem;
  text-shadow:1px -1px 18px #07c6ff;
}
.top-header h2 span{
  color: #186cd1;
}
.top-header a{
  text-decoration: none;
  color: #ccc;
  font-weight: 600;
}
header {
  background:linear-gradient(rgba(0, 0, 0, 0.7),rgba(1, 41, 105, 0.4)),url("../images/header-img.jfif") ;
  background-position: center;
  background-size: 100% 100%;
  color: #fff;
  padding: 50px 4.3rem;
  display: flex;
  flex-wrap: wrap;
  align-items:center;
  justify-content: space-between;
  text-align: center;
}

header .subtitle {
  font-size: 1.5rem;
  font-weight: 700;
}

header h1 {
  font-size: 20px;
  font-weight: normal;
  color: #ebebeb;
  padding-top: 1.5rem;
}

.dollar-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: center;
}

.dollar-box .label {
  font-size: 14px;
  color: #2ece02;
}
.dollar-box .changes{
  text-decoration: none;
  color: white;
  padding: 0.3rem 0.4rem;
  background-color: inherit;
  border: 1px solid rgb(213, 213, 213);
  border-radius: 0.3rem;
  margin-top: 0.8rem;
}
.dollar-box .changes:hover{
  background-color: rgba(255,255,255,0.2)
}

.dollar-box .dollar-price {
  font-size: 32px;
  font-weight: bold;
  color: #ffffff;
  display: inline-block;
}
.dollar-box .dollar-price.loading-text {
  font-size: 20px;
  opacity: 0.85;
  font-weight: 500;
}
 .calculator{
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: 3.4rem;
  height: 3.4rem;
  background-color: rgb(2, 145, 2);
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  z-index: 10;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(0,0,0,.22);
}
.calculator-item{
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}
.calculator-icon{
  width: 1.85rem;
  height: 1.85rem;
  color: #fff;
  display: block;
  transition: transform .2s ease;
}
.calculator-label{
  position: absolute;
  right: 3.1rem;
  white-space: nowrap;
  background-color: rgb(2, 145, 2);
  padding: .45rem .8rem;
  color: white;
  opacity: 0;
  pointer-events: none;
  transform: translateX(.5rem);
  transition: opacity .2s ease, transform .2s ease;
  border-radius: .6rem;
}
.calculator:hover .calculator-icon{
  transform: scale(1.08);
}
.calculator:hover .calculator-label{
  opacity: 1;
  transform: translateX(0);
}

/* ---------- محتوای اصلی ---------- */
main {
  max-width: 900px;
  margin: 24px auto;
  padding: 0 16px;
}

.price-section {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
  box-shadow:0 1px 20px 4px rgba(0, 0, 0, 0.1);
  overflow-x: auto;
}

.price-section h2 {
  font-size: 18px;
  margin-bottom: 12px;
  border-bottom: 2px solid #eee;
  padding-bottom: 8px;
}

/* ---------- جدول‌ها ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 400px;
}

thead {
  background-color: #f0f0f0;
}
th, td {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
}

th {
  font-size: 14px;
  color: #555;
}

td {
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

tbody tr:hover {
  background-color: #fafafa;
}

/* ---------- فوتر ---------- */
footer {
  text-align: center;
  padding: 20px;
  font-size: 13px;
  color: #888;
  background-color: #000026;
  gap: 0.5rem;
  display: flex;
  flex-direction: column;
}

/* ---------- ریسپانسیو ---------- */
@media (max-width: 600px) {
  .dollar-box {
    align-items: flex-start;
  }
  header{
    padding:30px 1.7rem ;
  }
  .top-header{
    padding: 1rem 3rem;
  }

  .dollar-box .dollar-price {
    font-size: 26px;
  }

  th, td {
    padding: 8px 6px;
    font-size: 13px;
  }
}
@media (max-width: 459px) {
   header {
    align-items: center;
    justify-content: space-between;
    gap: 3rem;
    padding: 30px 20px;
  }
  .top-header{
    padding: 1rem 1rem;
  }

}

@media (max-width: 400px) {
  header h1{
    padding: 1rem;
  }
}


/* ---------- رنگ تغییر قیمت؛ منطق قبلی سایت دست‌نخورده مانده است ---------- */
.change-up {
  color: #159447 !important;
  font-weight: 700;
}
.change-down {
  color: #d62828 !important;
  font-weight: 700;
}
.change-neutral {
  color: inherit !important;
  font-weight: 500;
}


/* ---------- نوار وضعیت اتصال (زیر هدر، بالای اولین جدول) ---------- */
.status-bar {
  display: none;
  box-sizing: border-box;
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
  padding: 10px 20px;
  border-radius: 10px;
}
.status-bar:not(:empty) {
  display: block;
  margin: 16px auto;
}
.status-bar.status-loading {
  background: #eef1f4;
  color: #55606b;
}
.status-bar.status-cached {
  background: #fff6e6;
  color: #8a5b00;
  border: 1px solid #ffe1a3;
}
.status-bar.status-error {
  background: #fdecea;
  color: #b3261e;
  border: 1px solid #f6cbc7;
}
.status-bar.status-live {
  background: transparent;
  color: #8a8f98;
}

@media (max-width: 600px) {
  .status-bar {
    max-width: none;
    margin: 12px 16px;
    padding: 8px 14px;
    font-size: 12.5px;
  }
}

/* ---------- هدر موبایل: چینش متقارن و جمع‌وجور ---------- */
@media (max-width: 600px) {
  .top-header {
    padding: 0.7rem 1rem;
    gap: 0.75rem;
  }
  .top-header h2 {
    font-size: 1.05rem;
    line-height: 1.5;
    text-align: right;
    flex: 1;
  }
  .top-header h2 span {
    font-size: 0.95rem;
    white-space: nowrap;
  }
  .top-header a {
    font-size: 0.85rem;
    white-space: nowrap;
    padding: 0.3rem 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
  }
  header {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.4rem;
    padding: 28px 1.2rem 32px;
  }
  header .title {
    text-align: center;
  }
  header h1 {
    padding: 0;
    font-size: 18px;
  }
  header .subtitle {
    font-size: 1.35rem;
    margin-top: 0.3rem;
  }
  .dollar-box {
    align-items: center;
    width: 100%;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.8rem;
  }
  .dollar-box .changes {
    margin-top: 0.7rem;
    padding: 0.35rem 1rem;
  }
}
@media (max-width: 400px) {
  header h1 {
    padding: 0;
  }
}

/* ---------- چرخش نرخ در هدر صفحه اصلی ---------- */
.dollar-box .label,
.dollar-box .dollar-price {
  transition: opacity var(--header-fade, 700ms) ease-in-out,
              transform var(--header-fade, 700ms) ease-in-out;
}
.dollar-box.is-switching .label,
.dollar-box.is-switching .dollar-price {
  opacity: 0;
  transform: translateY(6px);
}
@media (prefers-reduced-motion: reduce) {
  .dollar-box .label,
  .dollar-box .dollar-price { transition: none; }
}

/* ---------- فاصله‌ی آخرین جدول تا فوتر ---------- */
main .price-section:last-of-type {
  margin-bottom: 72px;
}
@media (max-width: 600px) {
  main .price-section:last-of-type {
    margin-bottom: 56px;
  }
}

/* ---------- نمودار با کلیک روی ردیف جدول (پنل تیره‌ی حرفه‌ای) ---------- */
tbody tr[id] { cursor: pointer; }
body.chart-open { overflow: hidden; }
.chart-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 8, 20, 0.62);
}
.chart-overlay[hidden] { display: none; }
.chart-panel {
  width: 100%;
  max-width: 600px;
  max-height: 94vh;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 18px 16px 22px;
  color: #e6edf6;
  background: linear-gradient(160deg, #001421, #00254b);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.4);
}
@media (min-width: 700px) {
  .chart-overlay { align-items: center; }
  .chart-panel { border-radius: 18px; padding: 24px; }
}
.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.chart-head h3 { margin: 0; font-size: 16px; font-weight: 600; color: #9db4cc; }
.chart-price { margin-top: 4px; font-size: 26px; font-weight: 700; color: #fff; }
.chart-price small { font-size: 13px; font-weight: 500; color: #9db4cc; }
.chart-chip {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 999px;
}
.chart-chip:empty { display: none; }
.chart-chip-up { color: #22c55e; background: rgba(34, 197, 94, 0.15); }
.chart-chip-down { color: #ef4444; background: rgba(239, 68, 68, 0.15); }
.chart-chip-flat { color: #9db4cc; background: rgba(157, 180, 204, 0.15); }
.chart-close {
  width: 36px; height: 36px;
  font-size: 22px; line-height: 1;
  color: #9db4cc; background: rgba(255, 255, 255, 0.08);
  border: 0; border-radius: 50%; cursor: pointer;
}
.chart-close:hover { background: rgba(255, 255, 255, 0.16); }
.chart-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 16px 0 12px;
}
.chart-seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 10px;
}
.chart-period,
.chart-mode {
  padding: 6px 8px;
  font: inherit;
  font-size: 12.5px;
  white-space: nowrap;
  color: #a9bdd3;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.chart-period[aria-pressed="true"],
.chart-mode[aria-pressed="true"] {
  color: #fff;
  background: #186cd1;
  font-weight: 700;
}
.chart-plot {
  position: relative;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.chart-svg { display: block; width: 100%; direction: ltr; }
.chart-svg text { direction: ltr; unicode-bidi: plaintext; }
.chart-grid { stroke: rgba(255, 255, 255, 0.08); stroke-width: 1; }
.chart-grid-v { stroke: rgba(255, 255, 255, 0.045); }
.chart-axis-text { font-size: 10.5px; fill: #8da4bd; }
.chart-last-text { fill: #fff; font-weight: 700; }
.chart-cross { stroke: #6f8aa8; stroke-width: 1; stroke-dasharray: 3 3; }
.chart-tip {
  position: absolute;
  top: 8px;
  transform: translateX(-50%);
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
  color: #fff;
  background: #0d2540;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  pointer-events: none;
  text-align: center;
}
.chart-tip b { display: block; font-size: 13px; }
.chart-tip-time { display: block; margin-top: 2px; color: #9db4cc; }
.chart-tip-ohlc {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 14px;
  text-align: right;
  direction: rtl;
}
.chart-tip-ohlc b { grid-column: 1 / -1; text-align: center; margin-bottom: 3px; color: #9db4cc; font-weight: 600; }
.chart-tip-ohlc span { color: #9db4cc; }
.chart-tip-ohlc em { font-style: normal; font-weight: 700; direction: ltr; text-align: left; }
.chart-empty {
  display: flex; align-items: center; justify-content: center;
  min-height: 200px; padding: 0 12px;
  text-align: center; line-height: 2; font-size: 14px; color: #9db4cc;
  background: rgba(255, 255, 255, 0.05); border-radius: 12px;
}
.chart-stats { display: flex; gap: 8px; margin-top: 14px; }
.chart-stat {
  flex: 1; display: flex; flex-direction: column; gap: 4px;
  padding: 10px 6px; text-align: center;
  background: rgba(255, 255, 255, 0.06); border-radius: 10px;
}
.chart-stat span { font-size: 12px; color: #8da4bd; }
.chart-stat strong { font-size: 13px; color: #fff; }
.chart-note { margin: 12px 0 0; font-size: 12px; color: #f2c46b; line-height: 1.8; }
.chart-note:empty { display: none; }

/* ---------- جدول‌ها روی گوشی: هر ردیف یک کارت دو خطی (بدون اسکرول افقی) ---------- */
@media (max-width: 600px) {
  .price-section table,
  .price-section tbody {
    display: block;
    width: 100%;
    min-width: 0;
  }
  .price-section thead {
    display: none;
  }
  .price-section tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "name price"
      "pct chg";
    align-items: center;
    gap: 4px 14px;
    padding: 12px 4px;
    border-bottom: 1px solid #eceff3;
  }
  .price-section tbody tr:last-child {
    border-bottom: 0;
  }
  .price-section tbody td {
    display: block;
    padding: 0;
    border: 0;
    text-align: start;
    white-space: nowrap;
  }
  .price-section tbody td:nth-child(1) { grid-area: name; font-weight: 700; font-size: 15px; }
  .price-section tbody td:nth-child(2) { grid-area: pct; font-size: 13px; }
  .price-section tbody td:nth-child(3) { grid-area: chg; justify-self: end; font-size: 13px; }
  .price-section tbody td:nth-child(4) { grid-area: price; justify-self: end; font-weight: 700; font-size: 16px; }
}

/* ---------- لوگوی GLCR در نوار بالا ---------- */
.top-header h2 .brand {
  display: inline-block;
  vertical-align: middle;
  margin-inline-start: 0.4rem;
}
.top-header h2 .brand img {
  display: block;
  height: 28px;
  width: auto;
}
@media (max-width: 600px) {
  .top-header h2 .brand img { height: 22px; }
}

/* ---------- ردیف تب‌ها زیر نوار بالا ---------- */
.top-header {
  justify-content: center;
}
.top-header h2 {
  text-align: center;
}
.site-tabs {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: linear-gradient(45deg, #001421, #00254b);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.site-tabs a {
  padding: 7px 18px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  color: #a9bdd3;
  text-decoration: none;
  border-radius: 999px;
}
.site-tabs a:hover { color: #fff; }
.site-tabs a[aria-current="page"] {
  color: #fff;
  background: #186cd1;
}
.site-tabs a:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
@media (max-width: 400px) {
  .site-tabs { gap: 2px; padding: 8px 6px; }
  .site-tabs a { padding: 7px 12px; font-size: 13px; }
}
footer a {
  color: #9fb3c8;
  text-decoration: underline;
}
