/* assets/css/components.css */
/* Scope: reusable UI components (buttons, inputs, cards, pills, headings) */

/* -----------------------------
   Headings (class-based)
----------------------------- */
.h1 {
  font-size: var(--fs-4);
  font-weight: var(--fw-bold);
  margin: 0;
  letter-spacing: -0.2px;
}

.h2 {
  font-size: var(--fs-2);
  font-weight: var(--fw-bold);
  margin: 0;
}

/* -----------------------------
   Card
----------------------------- */
.card {
  background: var(--surface-1);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-1);
}
/* materials list: clickable cards should not show ugly link focus/tap artifacts */
.material-card {
  -webkit-tap-highlight-color: transparent; /* iOS tap flash */
  text-decoration: none;
  color: inherit;
}

.material-card:focus,
.material-card:focus-visible {
  outline: none;
}
/* -----------------------------
   Input / Select
----------------------------- */
.input {
  width: 100%;
  height: var(--control-h);
  padding: 0 var(--control-pad-x);
  border-radius: var(--control-radius);
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-main);
  font-size: 16px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.input::placeholder {
  color: var(--color-ink-300);
  opacity: 1;
}

.input:hover {
  border-color: var(--border-soft);
}

.input:focus-visible {
  border-color: var(--color-line-focus);
  box-shadow: var(--focus-ring);
}
.input--center {
  text-align: center;
}
.input:disabled {
  opacity: 1;
  color: var(--text-muted);
  background: var(--surface-2);
  border-color: var(--border-soft);
  cursor: not-allowed;
}

.input:read-only,
.input[readonly] {
  background: var(--color-neutral-50);
  border-color: var(--border-soft);
}

/* -----------------------------
   Search helpers
----------------------------- */
.search-row{
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.search-clear{
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 12px;
  font-size: 18px;
  line-height: 1;
}
.search-meta{
  font-size: 12px;
  white-space: nowrap;
  margin-inline-start: auto;
}
mark.search-hl{
  background: rgba(229, 170, 23, 0.28);
  border-radius: 4px;
  padding: 0 2px;
}

/* textarea (if needed later) */
.textarea {
  width: 100%;
  min-height: 120px;
  padding: var(--space-3);
  border-radius: var(--control-radius);
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-main);
  font-size: 16px;
  resize: vertical;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.textarea::placeholder {
  color: var(--color-ink-300);
  opacity: 1;
}

.textarea:hover {
  border-color: var(--border-soft);
}

.textarea:focus-visible {
  border-color: var(--color-line-focus);
  box-shadow: var(--focus-ring);
}

.textarea:disabled {
  opacity: 1;
  color: var(--text-muted);
  background: var(--surface-2);
  border-color: var(--border-soft);
  cursor: not-allowed;
}

.textarea:read-only,
.textarea[readonly] {
  background: var(--color-neutral-50);
  border-color: var(--border-soft);
}

/* -----------------------------
   Button
----------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  height: var(--control-h);
  padding: 0 var(--space-4);
  border-radius: var(--control-radius);

  font-size: var(--fs-2);
  font-weight: var(--fw-bold);

  user-select: none;
  border: 1px solid transparent;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.72;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn--primary {
  background: var(--accent);
  color: var(--color-ink-900);
  box-shadow: var(--shadow-1);
  border-color: rgba(157, 112, 14, 0.32);
}

.btn--primary:hover {
  filter: brightness(0.98);
}

.btn--primary:focus-visible {
  box-shadow: var(--shadow-1), var(--focus-ring);
}

.btn--secondary {
  background: var(--surface-2);
  color: var(--text-main);
  border-color: var(--border);
}

.btn--secondary:focus-visible {
  box-shadow: var(--focus-ring);
}

.btn--ghost {
  background: transparent;
  color: var(--text-main);
  border-color: var(--border);
}

.btn--ghost:hover {
  background: rgba(42, 38, 33, 0.04);
}

.btn--ghost:focus-visible {
  box-shadow: var(--focus-ring);
}

.btn--primary:disabled,
.btn--secondary:disabled,
.btn--ghost:disabled {
  color: var(--text-muted);
  border-color: var(--border-soft);
}

.btn--primary:disabled,
.btn--secondary:disabled {
  background: var(--surface-2);
}

/* -----------------------------
   Pill / Badge
----------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  height: 28px;
  padding: 0 var(--space-3);

  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  color: var(--text-main);
  font-size: var(--fs-1);
  font-weight: var(--fw-bold);
}

.pill--accent {
  background: rgba(229, 170, 23, 0.18);
  color: var(--color-ink-900);
}

/* -----------------------------
   Topbar (light header)
----------------------------- */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
     gap: var(--space-3);
  }
}
/* -----------------------------
   App Header (minimal, sticky)
----------------------------- */
.app-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: var(--space-3);

  align-self: center;
  width: calc(100% - var(--space-4) - var(--space-4));
  max-width: calc(1100px - var(--space-4) - var(--space-4));
  margin-inline: auto;

  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-xl);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));

  position: sticky;
  top: calc(var(--space-3) + env(safe-area-inset-top));
  z-index: 1000;
  overflow: hidden;
  isolation: isolate;

  transition:
    opacity .25s ease,
    transform .25s ease,
    box-shadow .25s ease,
    background .25s ease,
    padding .25s ease;
}

.app-head::before{
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.66), rgba(255,255,255,0.2));
}

.app-head > *{
  position: relative;
  z-index: 1;
}

.app-head.is-compact{
  opacity: .72;
  transform: translateY(-2px);
  box-shadow: var(--shadow-1);
  background: rgba(255,255,255,.46);
}

.app-head__ws{
  display:flex;
  flex-direction: column;
  align-items:flex-start;
  min-width:0;
  gap:4px;
}

.app-head__ws-title{
  font-weight:700;
  font-size:13px;
  color: var(--text-main);
  text-decoration: none;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.app-head__ws-title:hover{
  color: var(--color-ink-700);
}
.app-head__ws-title:focus-visible{
  box-shadow: var(--focus-ring);
  border-radius: 10px;
}
.app-head__title{
  font-size:12px;
  opacity:.75;
  line-height:1.2;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.app-head__profile{
  display:flex;
  align-items:center;
}

.app-profile{
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border-radius:12px;
  text-decoration:none;
  color:inherit;
  background: rgba(255,255,255,0.52);
  border: 1px solid var(--border-soft);
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}
.app-profile:hover{
  background: rgba(255,255,255,0.74);
  border-color: var(--border);
}
.app-profile:focus-visible{
  box-shadow: var(--focus-ring);
}

.app-profile__icon{ font-size:18px; line-height:1; }
.app-profile__label{
  font-size:12px;
  opacity:.85;
  white-space:nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 128px;
}
.app-profile__label[dir="ltr"]{
  unicode-bidi: isolate;
  direction:ltr;
  letter-spacing:.2px;
}

@media (max-width: 640px) {
  .app-head{
    width: calc(100% - var(--space-3) - var(--space-3));
    max-width: calc(1100px - var(--space-3) - var(--space-3));
    padding:10px var(--space-3);
  }
}
@media (prefers-reduced-motion: reduce){
  .app-head{
    transition: none;
  }
}
/* -----------------------------------------
   Bottom Nav (Telegram-inspired / Minimal Glass)
------------------------------------------ */

:root{
  --bn-blur: 14px;
  --bn-text: rgba(42, 38, 33, 0.62);
  --bn-text-active: var(--accent);
  --bn-active-bg: rgba(229, 170, 23, 0.1);
  --bn-dot: rgba(229, 170, 23, 0.86);
  --bn-veil-blur: 10px;
}

.calc-bottom-nav-veil{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: env(safe-area-inset-bottom, 0px);
  z-index: 997;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(250,249,246,.1) 0%, rgba(250,249,246,.44) 100%);
  -webkit-backdrop-filter: blur(var(--bn-veil-blur)) saturate(118%);
  backdrop-filter: blur(var(--bn-veil-blur)) saturate(118%);
}

.calc-bottom-nav{
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: env(safe-area-inset-bottom, 0px);
  z-index: 999;

  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;

  padding: 8px;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.42);

  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--bn-blur)) saturate(130%);
  backdrop-filter: blur(var(--bn-blur)) saturate(130%);

  box-shadow: 0 4px 14px rgba(42, 38, 33, 0.08);
  overflow: hidden;
}

html.keyboard-open .calc-bottom-nav{
  opacity: 0;
  pointer-events: none;
  transform: translateY(120%);
  display: none;
}

html.keyboard-open .calc-bottom-nav-veil{
  opacity: 0;
  pointer-events: none;
  display: none;
}

.calc-bottom-nav::before{
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.46), rgba(255,255,255,0.08) 54%, rgba(255,255,255,0));
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))){
  .calc-bottom-nav-veil{
    background: rgba(250,249,246,.48);
  }
  .calc-bottom-nav{
    background: rgba(250,249,246,0.94);
  }
  .calc-bottom-nav::before{
    display: none;
  }
}

.calc-bottom-nav .bn-item{
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  gap: 3px;
  padding: 6px 4px 10px;
  border-radius: 14px;

  text-decoration: none;
  color: var(--bn-text);
  background: transparent;
  border: 1px solid transparent;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;

  transition: color .14s ease, background-color .14s ease, border-color .14s ease, transform .12s ease;
}

.calc-bottom-nav .bn-ico{
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.calc-bottom-nav .bn-ico .bn-svg{
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.calc-bottom-nav .bn-txt{
  font-size: 11px;
  font-weight: var(--fw-medium);
  line-height: 1.15;
  white-space: nowrap;
  color: inherit;
}

.calc-bottom-nav .bn-item.is-active{
  color: var(--bn-text-active);
  background: var(--bn-active-bg);
  border-color: rgba(229, 170, 23, 0.18);
}

.calc-bottom-nav .bn-item.is-active::after{
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  transform: translateX(-50%);
  background: var(--bn-dot);
}

.calc-bottom-nav .bn-item:active{
  transform: scale(0.98);
}

.calc-bottom-nav .bn-item:focus-visible{
  outline: none;
  box-shadow: var(--focus-ring);
}

@media (max-width: 360px){
  .calc-bottom-nav{
    left: 6px;
    right: 6px;
    border-radius: 20px;
    padding: 7px;
  }
  .calc-bottom-nav .bn-item{
    min-height: 50px;
    padding: 5px 3px 9px;
  }
  .calc-bottom-nav .bn-txt{
    font-size: 10px;
  }
}

@media (min-width: 900px){
  .calc-bottom-nav-veil{
    display: none;
  }
  .calc-bottom-nav{
    display: none;
  }
}
[hidden] { display: none !important; }
.toast{
  position: fixed;
  left: 12px;
  right: 12px;
  top: calc(10px + env(safe-area-inset-top));
  z-index: 9999;

  padding: 12px 14px;
  border-radius: var(--radius-lg);

  /* Liquid glass */
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));

  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-3);

  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  overflow: hidden;
}

.toast::before{
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.62), rgba(255,255,255,.2));
  opacity: .7;
}

.toast > *{
  position: relative;
  z-index: 1;
}

.toast.is-show{
  opacity: 1;
  transform: translateY(0);
}

.toast--ok{
  border-color: rgba(46,157,91,.35);
}
.toast--err{
  border-color: rgba(199,74,69,.4);
  background: rgba(255,240,238,.92);
  color: #74211f;
}
@media (prefers-color-scheme: dark){
  .toast{
    background: rgba(20,20,20,.80);
    border-color: rgba(255,255,255,.10);
    color: rgba(255,255,255,.92);
  }
  .toast::before{
    background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
  }
  .toast--err{
    background: rgba(60,20,20,.78);
    border-color: rgba(255,120,120,.35);
    color: rgba(255,220,220,.95);
  }
}

/* اگر blur پشتیبانی نشود */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))){
  .toast{
    background: rgba(255,255,255,.96);
  }
  .toast--err{
    background: rgba(255,240,238,.96);
  }
}
