/* Aniyab UI — Table
 * From Figma: Components / Table
 *
 * Usage:
 *   <div class="ay-table-wrap">
 *     <table class="ay-table">
 *       <thead>
 *         <tr>
 *           <th>
 *             <div class="ay-table__cell ay-table__cell--head">
 *               <span class="ay-table__sort" data-dir="none">…</span>
 *               <span class="ay-table__label">عنوان</span>
 *               <span class="ay-table__info">…</span>
 *               <label class="ay-check">…</label>
 *             </div>
 *           </th>
 *         </tr>
 *       </thead>
 *       <tbody>
 *         <tr>
 *           <td>
 *             <div class="ay-table__cell">
 *               <span class="ay-table__label">عنوان</span>
 *               <span class="ay-table__info">…</span>
 *               <label class="ay-check">…</label>
 *             </div>
 *           </td>
 *         </tr>
 *       </tbody>
 *     </table>
 *   </div>
 */

.ay-table-wrap {
  box-sizing: border-box;
  width: 100%;
  overflow: auto;
  background: var(--ay-surface-white, #FFFFFF);
  border: 1px solid var(--ay-border-light, #E7E5E4);
  border-radius: var(--ay-radius-table, 12px);
}

.ay-table {
  box-sizing: border-box;
  width: 100%;
  min-width: 640px;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--ay-font-family, dana, IRANSansfanum, Tahoma, sans-serif);
  color: var(--ay-text-main, #404040);
}

.ay-table th,
.ay-table td {
  box-sizing: border-box;
  padding: 0;
  vertical-align: middle;
  text-align: start;
  font-weight: inherit;
}

/* ----- Cell shell ----- */

.ay-table__cell {
  box-sizing: border-box;
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  height: 64px;
  padding: 8px 16px;
  background: var(--ay-surface-white, #FFFFFF);
  border-bottom: 1px solid #FEFEFE;
  color: var(--ay-text-main, #404040);
  font-weight: 500;
  font-size: 14px;
  line-height: 28px;
  white-space: nowrap;
}

.ay-table__cell--head {
  min-height: 48px;
  height: 48px;
  background: var(--ay-bg-dark, #F4F4F5);
  border-bottom: 1px solid var(--ay-border-dark, #D6D3D1);
  color: var(--ay-text-tertiary, #A3A3A3);
  font-weight: 700;
  font-size: 14px;
  line-height: 28px;
}

/* Zebra rows */
.ay-table tbody tr:nth-child(even) .ay-table__cell {
  background: var(--ay-bg-light, #FAFAFA);
}

.ay-table tbody tr:nth-child(odd) .ay-table__cell {
  background: var(--ay-surface-white, #FFFFFF);
}

.ay-table tbody tr:last-child .ay-table__cell {
  border-bottom: 0;
}

.ay-table tbody tr:hover .ay-table__cell {
  background: #F0F4FA;
}

/* ----- Cell parts ----- */

.ay-table__label {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: inherit;
}

.ay-table__cell--head .ay-table__label {
  color: var(--ay-text-tertiary, #A3A3A3);
  font-weight: 700;
}

.ay-table__info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--ay-text-tertiary, #A3A3A3);
}

.ay-table__cell--head .ay-table__info {
  width: 24px;
  height: 24px;
  color: var(--ay-text-tertiary, #A3A3A3);
}

.ay-table__info svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
}

.ay-table__cell .ay-check,
.ay-table__cell .ay-radio {
  flex: none;
  min-height: 0;
}

.ay-table__cell .ay-check__control,
.ay-table__cell .ay-radio__control {
  width: 16px;
  height: 16px;
  padding: 0;
}

.ay-table__cell .ay-check__control::before,
.ay-table__cell .ay-radio__control::before {
  width: 16px;
  height: 16px;
}

.ay-table__cell .ay-check__label,
.ay-table__cell .ay-radio__label {
  display: none;
}

/* Filter / dropdown chevron (header) */
.ay-table__chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 24px;
  height: 24px;
  color: var(--ay-text-tertiary, #A3A3A3);
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.ay-table__chevron svg {
  display: block;
  width: 12px;
  height: 6px;
  fill: currentColor;
}

/* ----- Sort trigger ----- */

.ay-table__sort {
  box-sizing: border-box;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: none;
  gap: 4px;
  width: 18px;
  height: 18px;
  padding: 3px 5px;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--ay-text-secondary, #737373);
}

.ay-table__sort-icon {
  display: block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}

.ay-table__sort-icon--up {
  border-bottom: 4px solid currentColor;
}

.ay-table__sort-icon--down {
  border-top: 4px solid currentColor;
}

/* Direction states (Figma Sort Trigger) */
.ay-table__sort[data-dir="none"] .ay-table__sort-icon,
.ay-table__sort:not([data-dir]) .ay-table__sort-icon {
  color: var(--ay-border-dark, #D6D3D1);
}

.ay-table__sort[data-dir="default"] .ay-table__sort-icon {
  color: var(--ay-text-secondary, #737373);
}

.ay-table__sort[data-dir="down"] .ay-table__sort-icon--down {
  color: var(--ay-text-main, #404040);
}

.ay-table__sort[data-dir="down"] .ay-table__sort-icon--up {
  color: var(--ay-border-dark, #D6D3D1);
}

.ay-table__sort[data-dir="up"] .ay-table__sort-icon--up {
  color: var(--ay-text-main, #404040);
}

.ay-table__sort[data-dir="up"] .ay-table__sort-icon--down {
  color: var(--ay-border-dark, #D6D3D1);
}

/* Sticky header helper */
.ay-table--sticky thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.ay-table--sticky thead .ay-table__cell--head {
  box-shadow: 0 1px 0 var(--ay-border-dark, #D6D3D1);
}

/* Dense variant (optional) */
.ay-table--compact .ay-table__cell {
  min-height: 48px;
  height: 48px;
}
