/* ============================================================
   Gaýtadan ulanylýan komponentler
   ============================================================ */

/* ---------- Düwmeler ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-border: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.44rem 0.85rem;
  font: inherit;
  font-weight: 600;
  font-size: var(--fs-sm);
  line-height: 1.25;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease), filter var(--dur-fast) var(--ease);
}
.btn:hover { filter: brightness(0.96); color: var(--btn-fg); }
.btn:active { filter: brightness(0.92); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.45; cursor: not-allowed; filter: none; }
.btn .ico { flex: none; }

/* Esasy düwme — bitarap grafit (ýaşyl diňe ýokarky/aşaky zolaklarda) */
.btn--primary { --btn-bg: var(--action); --btn-fg: var(--action-text); --btn-border: var(--action); }
.btn--primary:hover { --btn-bg: var(--action-hover); --btn-border: var(--action-hover); }
.btn--gold { --btn-bg: var(--gold-600); --btn-fg: #fff; --btn-border: var(--gold-600); }
.btn--ghost { --btn-bg: transparent; --btn-border: var(--border-strong); }
.btn--ghost:hover { --btn-bg: var(--surface-3); }
.btn--soft { --btn-bg: var(--accent-soft); --btn-fg: var(--accent-strong); --btn-border: transparent; }
.btn--danger { --btn-bg: var(--danger-500); --btn-fg: #fff; --btn-border: transparent; }
.btn--sm { padding: 0.28rem 0.62rem; font-size: var(--fs-xs); }
.btn--lg { padding: 0.6rem 1.15rem; font-size: var(--fs-base); }
.btn--block { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}
.icon-btn:hover { color: var(--accent-strong); background: var(--surface-3); }
.icon-btn--sm { width: 27px; height: 27px; }
.icon-btn--menu { display: none; }

/* ---------- Nyşanlar (SVG) ---------- */
.ico { fill: currentColor; stroke: none; vertical-align: middle; }
.ico .ico-line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico .ico-hole { fill: var(--surface); }
.ico circle, .ico rect { fill: currentColor; }
.ico .ico-line { fill: none; }

/* ---------- Bellikler ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.12em 0.5em;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--surface-3);
  color: var(--text-soft);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.tag--accent { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.tag--gold { background: var(--gold-soft); color: var(--gold-700); border-color: var(--border-gold); }
.tag--demo { background: var(--gold-soft); color: var(--gold-700); border: 1px solid var(--border-gold); }
.tag--upcoming { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.tag--ongoing {
  background: var(--accent-soft); color: var(--accent-strong); border-color: transparent;
}
.tag--ongoing::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; animation: pulse 1.6s ease-in-out infinite;
}
.tag--completed { background: var(--surface-3); color: var(--text-muted); }
.tag--draft { background: var(--warn-100); color: var(--warn-600); border-color: transparent; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.72); } }

/* ---------- Kartlar ---------- */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.card--hover:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.card__body { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); flex: 1; }
.card__title { margin: 0; font-size: var(--fs-md); }
.card__meta { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); font-size: var(--fs-xs); color: var(--text-muted); }
.card__meta-item { display: inline-flex; align-items: center; gap: 0.4em; }
.card__foot {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  flex-wrap: wrap;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.panel--inset { background: var(--surface-2); box-shadow: none; }
.panel__title {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--fs-sm); font-weight: 700; margin-bottom: var(--space-3);
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-soft);
  font-family: var(--font-body);
}
.panel__title .ico { color: var(--gold); }

/* ---------- Statistika ---------- */
.stat {
  display: flex; flex-direction: column; gap: var(--space-1);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  position: relative;
}
.stat__value {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 600; line-height: 1.05; color: var(--accent-strong);
}
.stat__label { font-size: var(--fs-sm); color: var(--text-soft); }
.stat__hint { font-size: var(--fs-xs); color: var(--text-muted); }

/* ---------- Progres ---------- */
.progress {
  height: 4px; border-radius: var(--radius-pill);
  background: var(--surface-inset); overflow: hidden;
}
.progress__bar {
  height: 100%; border-radius: inherit;
  background: var(--accent);
  transition: width var(--dur-slow) var(--ease-out);
}
.progress--full .progress__bar { background: var(--clay-500); }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-3); }
.field__label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-soft); }
.field__hint { font-size: var(--fs-xs); color: var(--text-muted); }
.field__error { font-size: var(--fs-xs); color: var(--danger-500); font-weight: 600; min-height: 1em; }

.input, .select, .textarea {
  width: 100%;
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0.42rem 0.6rem;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
              background-color var(--dur-fast) var(--ease);
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.55; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.input[aria-invalid='true'], .textarea[aria-invalid='true'] {
  border-color: var(--danger-500);
  box-shadow: 0 0 0 2px var(--danger-100);
}
/* Ölçegi çäklendirilen giriş meýdanlary — mediýa-soraglar bilen dolandyrylýar */
.select--compact { max-width: 190px; }
.select--wide { max-width: 320px; }
.input--narrow { max-width: 110px; }

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
}
.checkbox { display: flex; align-items: flex-start; gap: var(--space-3); cursor: pointer; font-size: var(--fs-sm); }
.checkbox input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--action); flex: none; }

.field-row { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* Segment saýlaýjy */
.segment {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  flex-wrap: wrap;
}
.segment__btn {
  border: none; background: transparent; cursor: pointer;
  font: inherit; font-size: var(--fs-xs); font-weight: 600;
  color: var(--text-muted);
  padding: 0.26rem 0.6rem; border-radius: var(--radius-sm);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.segment__btn:hover { color: var(--text); }
.segment__btn.is-active { background: var(--surface); color: var(--accent-strong); box-shadow: var(--shadow-sm); }
/* Gözleg meýdany */
.search {
  position: relative; display: flex; align-items: center;
  flex: 1 1 240px; min-width: 200px;
}
.search .ico { position: absolute; inset-inline-start: 9px; color: var(--text-muted); pointer-events: none; }
.search .input { padding-inline-start: 2rem; }

/* ---------- Tablisa ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); min-width: 560px; }
.table th, .table td { padding: 0.46rem 0.7rem; text-align: start; border-bottom: 1px solid var(--border); }
.table th {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); background: var(--surface-2); font-weight: 700; white-space: nowrap;
}
.table tbody tr { transition: background-color var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table__actions { display: flex; gap: var(--space-2); justify-content: flex-end; }
.table td.num, .table th.num { text-align: end; font-variant-numeric: tabular-nums; }
.rank-1 { color: var(--gold); font-weight: 800; }
.rank-2 { color: var(--text-soft); font-weight: 700; }
.rank-3 { color: var(--clay-500); font-weight: 700; }

/* ---------- Habarnamalar (toast) ---------- */
.toast-root {
  position: fixed; inset-block-end: var(--space-5); inset-inline-end: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-3);
  z-index: 1200; pointer-events: none; max-width: min(380px, calc(100vw - 2rem));
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateX(28px) scale(.97);
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
.toast.is-open { opacity: 1; transform: none; }
.toast__icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); flex: none; }
.toast__text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.toast__title { font-size: var(--fs-sm); }
.toast__body { font-size: var(--fs-sm); color: var(--text-soft); }
.toast__close { border: none; background: none; cursor: pointer; color: var(--text-muted); padding: 2px; }
.toast--success { border-inline-start-color: var(--success-600); }
.toast--success .toast__icon { background: var(--success-100); color: var(--success-600); }
.toast--error { border-inline-start-color: var(--danger-500); }
.toast--error .toast__icon { background: var(--danger-100); color: var(--danger-600); }
.toast--demo { border-inline-start-color: var(--gold); }
.toast--demo .toast__icon { background: var(--gold-soft); color: var(--gold-700); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1300;
  display: grid; place-items: center;
  padding: var(--space-5);
  background: rgba(8, 26, 21, 0.5);
  opacity: 0; transition: opacity var(--dur) var(--ease);
  overflow-y: auto;
}
.modal-overlay.is-open { opacity: 1; }
.modal {
  width: 100%; max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  transform: translateY(16px) scale(.98);
  transition: transform var(--dur) var(--ease-out);
  max-height: calc(100vh - 3rem);
  display: flex; flex-direction: column;
}
.modal-overlay.is-open .modal { transform: none; }
.modal--sm { max-width: 420px; }
.modal--lg { max-width: 760px; }
.modal__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-4); border-bottom: 1px solid var(--border);
}
.modal__title { margin: 0; font-size: var(--fs-md); }
.modal__body { padding: var(--space-4); overflow-y: auto; }
.modal__message { color: var(--text-soft); }
.modal__foot {
  display: flex; justify-content: flex-end; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); background: var(--surface-2);
}

/* ---------- Üstki menýu ---------- */
.header {
  position: sticky; top: 0; z-index: 900;
  background: var(--chrome-bg);
  border-bottom: 2px solid var(--chrome-accent);
  transition: box-shadow var(--dur) var(--ease);
}
.header.is-scrolled { box-shadow: var(--shadow-md); }
.header__inner {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--header-h);
}
.header__actions { display: flex; align-items: center; gap: var(--space-2); margin-inline-start: auto; }

.brand { display: flex; align-items: center; gap: var(--space-3); flex: none; color: var(--text); }
.brand:hover { color: var(--text); }
/* Ýaşyl zolaklardaky brend (ýokarky menýu, aşaky bölüm, dolandyryş paneli) */
.header .brand, .header .brand:hover,
.footer .brand, .footer .brand:hover,
.admin-side .brand, .admin-side .brand:hover { color: var(--chrome-text); }
.header .brand__name,
.footer .brand__name,
.admin-side .brand__name { color: var(--chrome-text); }
.header .brand__tld,
.footer .brand__tld,
.admin-side .brand__tld { color: var(--chrome-accent); }
.header .brand__tagline,
.footer .brand__tagline,
.admin-side .brand__tagline { color: var(--chrome-muted); }
.brand__mark {
  display: grid; place-items: center;
  width: 32px; height: 32px; flex: none;
  border-radius: var(--radius-md);
  background: var(--surface-3);
  color: var(--gold-700);
}
.header .brand__mark,
.footer .brand__mark,
.admin-side .brand__mark {
  background: rgba(255, 255, 255, 0.1);
  color: var(--chrome-accent);
  box-shadow: inset 0 0 0 1px var(--chrome-border);
}
.brand__mark .ornament { width: 21px; height: 21px; }
.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
/* Domen görnüşli at nyşany — serif däl, inçe harp aralygy bilen */
.brand__name {
  font-family: var(--font-body);
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
}
.brand__tld { color: var(--gold); font-weight: 600; }
.brand__tagline { font-size: 0.625rem; color: var(--text-muted); letter-spacing: 0.02em; }

.nav { display: flex; align-items: center; gap: 1px; margin-inline-start: var(--space-4); flex-wrap: nowrap; }
.nav__link {
  display: inline-flex; align-items: center; gap: 0.4em;
  padding: 0.34rem 0.56rem; border-radius: var(--radius-sm);
  font-size: var(--fs-sm); font-weight: 500; color: var(--text-soft);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  position: relative;
}
.nav__ico { display: none; }
.nav__link:hover { background: var(--surface-3); color: var(--text); }
.nav__link.is-active { color: var(--accent-strong); font-weight: 700; }
.nav__link.is-active::after {
  content: ''; position: absolute; inset-inline: 0.56rem; inset-block-end: -1px;
  height: 2px; background: var(--accent);
}

/* Ýokarky ýaşyl zolakdaky menýu */
.header .nav__link { color: var(--chrome-text-soft); }
.header .nav__link:hover { background: rgba(255, 255, 255, 0.1); color: var(--chrome-text); }
.header .nav__link.is-active { color: var(--chrome-text); }
.header .nav__link.is-active::after { background: var(--chrome-accent); inset-block-end: -3px; height: 3px; }

/* Ýokarky zolakdaky nyşan düwmeleri */
.header .icon-btn {
  background: transparent; border-color: var(--chrome-border); color: var(--chrome-text-soft);
}
.header .icon-btn:hover { background: rgba(255, 255, 255, 0.12); color: var(--chrome-text); }
.header .btn--primary {
  --btn-bg: var(--chrome-accent); --btn-fg: #2a2206; --btn-border: var(--chrome-accent);
}

/* Gapdal menýu (mobil) */
.drawer { position: fixed; inset: 0; z-index: 1100; }
.drawer::before {
  content: ''; position: absolute; inset: 0;
  background: rgba(4, 22, 18, 0.5); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.drawer.is-open::before { opacity: 1; }
.drawer__panel {
  position: absolute; inset-block: 0; inset-inline-end: 0;
  width: min(88vw, 330px);
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: var(--space-4);
  padding: var(--space-5);
  transform: translateX(100%);
  transition: transform var(--dur) var(--ease-out);
  overflow-y: auto;
}
.drawer.is-open .drawer__panel { transform: none; }
.drawer__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.drawer__nav { display: flex; flex-direction: column; gap: var(--space-1); }
.nav__link--drawer { padding: 0.8rem 0.9rem; font-size: var(--fs-base); border-radius: var(--radius-md); }
.nav__link--drawer .nav__ico { display: inline-grid; place-items: center; color: var(--gold); }
.drawer__foot { margin-top: auto; }

/* ---------- Aşaky bölüm ---------- */
.footer {
  margin-top: var(--space-7);
  background: var(--chrome-bg);
  color: var(--chrome-text-soft);
  position: relative;
}
.footer__ornament {
  height: 5px;
  background-image:
    linear-gradient(135deg, var(--gold-500) 25%, transparent 25%),
    linear-gradient(225deg, var(--gold-500) 25%, transparent 25%),
    linear-gradient(45deg, var(--gold-500) 25%, transparent 25%),
    linear-gradient(315deg, var(--gold-500) 25%, transparent 25%);
  background-position: 5px 0, 5px 0, 0 0, 0 0;
  background-size: 5px 5px;
  opacity: 0.4;
}
.footer__inner {
  display: grid; gap: var(--space-5);
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  padding-block: var(--space-6) var(--space-5);
}
.footer__col--brand { grid-column: span 2; max-width: 38ch; }


.footer__about { margin-top: var(--space-3); font-size: var(--fs-sm); color: var(--chrome-text-soft); }
.footer__title {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--chrome-accent); margin-bottom: var(--space-3); font-family: var(--font-body); font-weight: 700;
}
.footer__list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.footer__list a { color: var(--chrome-text-soft); font-size: var(--fs-sm); }
.footer__list a:hover { color: var(--chrome-accent); }
.footer__list--plain li { color: var(--chrome-muted); font-size: var(--fs-sm); }
.footer__bottom {
  display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: space-between;
  padding-block: var(--space-4); border-top: 1px solid var(--chrome-border);
  color: var(--chrome-muted); font-size: var(--fs-xs);
}
.footer__note { max-width: 48ch; }

/* ---------- Sütünli diagramma (statistika we matematika görkezmeleri) ---------- */
.chart-bars { display: flex; align-items: flex-end; gap: var(--space-3); height: 160px; padding-top: var(--space-4); }
.chart-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: var(--space-2); height: 100%; justify-content: flex-end; }
.chart-bar__fill {
  width: 100%; max-width: 54px; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--accent);
  min-height: 4px; transition: height var(--dur-slow) var(--ease-out);
  display: grid; place-items: start center; color: #fff; font-size: var(--fs-xs); font-weight: 700; padding-top: 4px;
}
.chart-bar--gold .chart-bar__fill { background: var(--action); color: var(--action-text); }
.chart-bar__label { font-size: var(--fs-xs); color: var(--text-muted); text-align: center; }

/* ---------- Mobil ---------- */
@media (max-width: 940px) {
  .nav { display: none; }
  .icon-btn--menu { display: inline-grid; }
  .header__cta { display: none; }
}
@media (max-width: 640px) {
  :root { --header-h: 64px; }
  .brand__tagline { display: none; }
  .toast-root { inset-inline: var(--space-4); inset-block-end: var(--space-4); max-width: none; }
  .footer__col--brand { grid-column: span 1; }
  .card__body { padding: var(--space-4); }
  .container { padding-inline: var(--space-4); }
}
