/*
  Bileşen katmanı — sohbetbox.com bileşen ölçü ve durumlarıyla birebir.
  Tüm renk ve ölçüler tokens.css değişkenlerinden gelir.
*/

@layer tv.components {
  /* ================================================================ düğme */
  .tv-btn {
    --btn-bg: var(--surface);
    --btn-bg-hover: var(--surface-2);
    --btn-fg: var(--text);
    --btn-line: var(--line-2);
    --btn-line-hover: var(--line-strong);
    --btn-sh: var(--sh-1);
    --btn-h: var(--btn-h-md);
    --btn-px: var(--btn-px-md);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    height: var(--btn-h);
    padding: 0 var(--btn-px);
    border: 1px solid var(--btn-line);
    border-radius: var(--r-md);
    background: var(--btn-bg);
    color: var(--btn-fg);
    box-shadow: var(--btn-sh);
    font-size: var(--fs-sm);
    font-weight: var(--w-semi);
    letter-spacing: var(--tr-btn);
    white-space: nowrap;
    user-select: none;
    overflow: hidden;
    isolation: isolate;
    -webkit-tap-highlight-color: transparent;
    transition:
      background-color var(--d-2) var(--ease-soft),
      border-color var(--d-2) var(--ease-soft),
      color var(--d-2) var(--ease-soft),
      box-shadow var(--d-3) var(--ease-soft),
      transform var(--d-2) var(--ease-out);
  }

  .tv-btn:hover {
    background: var(--btn-bg-hover);
    border-color: var(--btn-line-hover);
    transform: translateY(var(--lift));
  }

  .tv-btn:active {
    transform: translateY(0) scale(0.975);
    transition-duration: var(--d-press);
  }

  .tv-btn:focus-visible {
    outline: none;
    box-shadow: var(--btn-sh), var(--ring-strong);
  }

  .tv-btn[disabled],
  .tv-btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
  }

  .tv-btn__ico {
    width: var(--ico-md);
    height: var(--ico-md);
    flex-shrink: 0;
    transition: transform var(--d-3) var(--ease-out);
  }

  .tv-btn:hover .tv-btn__ico--go {
    transform: translateX(var(--shift-x));
  }

  .tv-btn--primary {
    --btn-bg: var(--brand);
    --btn-bg-hover: var(--brand-strong);
    --btn-fg: var(--on-brand);
    --btn-line: transparent;
    --btn-line-hover: transparent;
    --btn-sh: var(--sh-brand);
    background-image: var(--btn-sheen-top);
  }

  .tv-btn--primary::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--btn-sheen-sweep);
    transform: translateX(-110%);
    transition: transform 0s;
  }

  .tv-btn--primary:hover::after {
    transform: translateX(110%);
    transition: transform var(--d-sheen) var(--ease-out);
  }

  .tv-btn--primary:hover {
    box-shadow: var(--sh-brand-lg);
  }

  .tv-btn--secondary {
    --btn-bg: var(--surface);
    --btn-bg-hover: var(--surface);
  }

  .tv-btn--secondary:hover {
    box-shadow: var(--sh-2);
  }

  .tv-btn--ghost {
    --btn-bg: transparent;
    --btn-bg-hover: var(--hover-brand-soft);
    --btn-line: transparent;
    --btn-line-hover: transparent;
    --btn-sh: none;
    --btn-fg: var(--text-2);
  }

  .tv-btn--ghost:hover {
    color: var(--text);
  }

  .tv-btn--light {
    --btn-bg: var(--btn-light-bg);
    --btn-bg-hover: var(--btn-light-bg);
    --btn-fg: var(--btn-light-fg);
    --btn-line: transparent;
    --btn-line-hover: transparent;
    --btn-sh: var(--btn-light-sh);
  }

  .tv-btn--glass {
    --btn-bg: var(--btn-glass-bg);
    --btn-bg-hover: var(--btn-glass-bg-hover);
    --btn-fg: var(--btn-glass-fg);
    --btn-line: var(--btn-glass-line);
    --btn-line-hover: var(--btn-glass-line-hover);
    --btn-sh: none;
  }

  .tv-btn--sm {
    --btn-h: var(--btn-h-sm);
    --btn-px: var(--btn-px-sm);
    font-size: var(--fs-xs);
    border-radius: var(--r-sm);
  }

  .tv-btn--lg {
    --btn-h: var(--btn-h-lg);
    --btn-px: var(--btn-px-lg);
    font-size: var(--fs-body);
    border-radius: var(--r-btn-lg);
  }

  .tv-btn--block {
    width: 100%;
  }

  .tv-btn--icon {
    --btn-px: var(--s-0);
    width: var(--btn-h);
  }

  .tv-btn[data-state="loading"] {
    color: transparent;
    pointer-events: none;
  }

  .tv-btn[data-state="loading"]::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: var(--ico-md);
    height: var(--ico-md);
    margin: calc(var(--s-2) * -1) 0 0 calc(var(--s-2) * -1);
    border-radius: var(--r-pill);
    border: var(--s-half) solid var(--btn-fg);
    border-right-color: transparent;
    border-bottom-color: transparent;
    animation: tv-spin 0.7s linear infinite;
  }

  .tv-btn[data-state="success"] {
    --btn-bg: var(--ok);
    --btn-bg-hover: var(--ok);
    --btn-fg: var(--on-brand);
    --btn-line: transparent;
  }

  .tv-btn[data-state="error"] {
    --btn-bg: var(--err-tint);
    --btn-bg-hover: var(--err-tint);
    --btn-line: var(--err);
    --btn-fg: var(--err);
    background-image: none;
    box-shadow: none;
    animation: tv-shake var(--d-3) var(--ease-out);
  }

  /* ================================================================ metin bağlantısı */
  .tv-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--s-1h);
    font-weight: var(--w-semi);
    font-size: var(--fs-sm);
    color: var(--brand-text);
    background-image: linear-gradient(currentColor, currentColor);
    background-size: 0% var(--s-half);
    background-position: 0 100%;
    background-repeat: no-repeat;
    transition: background-size var(--d-3) var(--ease-out), color var(--d-2);
  }

  .tv-link:hover {
    background-size: 100% var(--s-half);
  }

  .tv-link svg {
    width: var(--ico-sm);
    height: var(--ico-sm);
    transition: transform var(--d-3) var(--ease-out);
  }

  .tv-link:hover svg {
    transform: translateX(var(--shift-x));
  }

  /* ================================================================ çip ve rozet */
  .tv-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--s-1h);
    height: var(--chip-h);
    padding: 0 var(--chip-px);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--text-2);
    font-size: var(--fs-2xs);
    font-weight: var(--w-med);
    white-space: nowrap;
    transition:
      border-color var(--d-2),
      color var(--d-2),
      background-color var(--d-2),
      transform var(--d-2) var(--ease-out);
  }

  a.tv-chip:hover,
  button.tv-chip:hover,
  .tv-chip[aria-pressed="true"],
  .tv-chip.is-active {
    border-color: var(--brand-line);
    background: var(--brand-tint);
    color: var(--brand-text);
    transform: translateY(var(--lift-sm));
  }

  .tv-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--s-1);
    height: var(--badge-h);
    padding: 0 var(--badge-px);
    border-radius: var(--r-pill);
    font-family: var(--f-code);
    font-size: var(--fs-badge);
    font-weight: var(--w-med);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: var(--surface-3);
    color: var(--text-3);
    white-space: nowrap;
  }

  .tv-badge--live {
    background: var(--ok-tint);
    color: var(--ok-text);
  }

  .tv-badge--live::before {
    content: "";
    width: var(--dot-sm);
    height: var(--dot-sm);
    border-radius: var(--r-pill);
    background: currentColor;
    animation: tv-blink 2.4s ease-in-out infinite;
  }

  .tv-badge--soon {
    background: transparent;
    border: 1px dashed var(--line-strong);
    color: var(--text-3);
  }

  .tv-badge--brand {
    background: var(--brand-tint);
    color: var(--brand-text);
  }

  /* ================================================================ kart */
  .tv-card {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    padding: var(--s-6);
    border: 1px solid var(--card-line);
    border-radius: var(--r-lg);
    background: var(--card-bg);
    box-shadow: var(--card-sh);
    transition:
      transform var(--d-3) var(--ease-out),
      box-shadow var(--d-3) var(--ease-soft),
      border-color var(--d-3) var(--ease-soft);
  }

  .tv-card--hover::before {
    content: "";
    position: absolute;
    inset: calc(var(--s-px) * -1);
    border-radius: inherit;
    padding: var(--s-px);
    background: radial-gradient(var(--card-glow-r) circle at var(--mx, 50%) var(--my, 50%), var(--card-glow), transparent 65%);
    -webkit-mask: linear-gradient(var(--mask-solid) 0 0) content-box, linear-gradient(var(--mask-solid) 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--d-3) var(--ease-soft);
  }

  .tv-card--hover:hover {
    transform: translateY(var(--lift));
    box-shadow: var(--card-sh-hover);
    border-color: var(--brand-line);
  }

  .tv-card--hover:hover::before {
    opacity: 1;
  }

  .tv-card__ico {
    width: var(--ico-box-lg);
    height: var(--ico-box-lg);
    border-radius: var(--r-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-tint);
    border: 1px solid var(--brand-line);
    color: var(--brand-text);
    flex-shrink: 0;
  }

  .tv-card__ico svg {
    width: var(--ico-lg);
    height: var(--ico-lg);
  }

  .tv-card__num {
    font-family: var(--f-code);
    font-size: var(--fs-2xs);
    font-weight: var(--w-med);
    color: var(--brand-text);
  }

  .tv-card__desc {
    font-size: var(--fs-sm);
    line-height: var(--lh-body);
    color: var(--text-2);
  }

  .tv-card__foot {
    margin-top: auto;
    padding-top: var(--s-3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
  }

  /* ================================================================ akordeon */
  .tv-acc {
    display: grid;
    gap: var(--s-3);
  }

  .tv-acc__item {
    border: 1px solid var(--card-line);
    border-radius: var(--r-lg);
    background: var(--card-bg);
    box-shadow: var(--sh-0);
    transition: border-color var(--d-2) var(--ease-soft), box-shadow var(--d-2) var(--ease-soft);
  }

  .tv-acc__item[open] {
    border-color: var(--brand-line);
    box-shadow: var(--sh-2);
  }

  .tv-acc__q {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    padding: var(--s-5) var(--s-6);
    cursor: pointer;
    font-family: var(--f-display);
    font-size: var(--fs-h4);
    font-weight: var(--w-semi);
    font-stretch: 96%;
    color: var(--text);
    user-select: none;
  }

  .tv-acc__q::-webkit-details-marker {
    display: none;
  }

  .tv-acc__plus {
    position: relative;
    width: var(--acc-btn);
    height: var(--acc-btn);
    border-radius: var(--r-pill);
    border: 1px solid var(--line-2);
    background: var(--surface-2);
    flex-shrink: 0;
    transition:
      background-color var(--d-2) var(--ease-soft),
      border-color var(--d-2) var(--ease-soft),
      transform var(--d-3) var(--ease-spring);
  }

  .tv-acc__plus::before,
  .tv-acc__plus::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: var(--s-3);
    height: var(--s-half);
    background: var(--text-2);
    border-radius: var(--r-pill);
    transform: translate(-50%, -50%);
    transition: transform var(--d-3) var(--ease-out), background-color var(--d-2);
  }

  .tv-acc__plus::after {
    transform: translate(-50%, -50%) rotate(90deg);
  }

  .tv-acc__item[open] .tv-acc__plus {
    background: var(--brand);
    border-color: var(--brand);
    transform: rotate(45deg);
  }

  .tv-acc__item[open] .tv-acc__plus::before,
  .tv-acc__item[open] .tv-acc__plus::after {
    background: var(--on-brand);
  }

  .tv-acc__a {
    padding: 0 var(--s-6) var(--s-6);
    font-size: var(--fs-sm);
    line-height: var(--lh-long);
    color: var(--text-2);
  }

  /* ================================================================ sekmeler */
  .tv-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: var(--s-1);
    padding: var(--s-1);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface-2);
  }

  .tv-tab {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    height: var(--btn-h-sm);
    padding: 0 var(--s-4);
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-2);
    font-size: var(--fs-xs);
    font-weight: var(--w-semi);
    transition: background-color var(--d-2), color var(--d-2), box-shadow var(--d-2);
  }

  .tv-tab svg {
    width: var(--ico-sm);
    height: var(--ico-sm);
    flex-shrink: 0;
  }

  .tv-tab:hover {
    color: var(--text);
  }

  .tv-tab[aria-selected="true"] {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--sh-1);
  }

  .tv-tabpanel[hidden] {
    display: none !important;
  }

  /* ================================================================ kod bloğu */
  .tv-code {
    border: 1px solid var(--ink-line);
    border-radius: var(--r-lg);
    background: var(--code-bg);
    color: var(--code-text);
    overflow: hidden;
    box-shadow: var(--sh-3);
    min-width: 0;
    max-width: 100%;
  }

  .tv-code__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    height: var(--code-bar-h);
    padding: 0 var(--s-4);
    background: var(--code-bar);
    border-bottom: 1px solid var(--ink-line);
  }

  .tv-code__left {
    display: inline-flex;
    align-items: center;
    gap: var(--s-3);
    min-width: 0;
  }

  .tv-code__dots {
    display: inline-flex;
    gap: var(--s-1h);
    flex-shrink: 0;
  }

  .tv-code__dots span {
    width: var(--dot-md);
    height: var(--dot-md);
    border-radius: var(--r-pill);
  }

  .tv-code__dots span:nth-child(1) {
    background: var(--code-dot-r);
  }

  .tv-code__dots span:nth-child(2) {
    background: var(--code-dot-y);
  }

  .tv-code__dots span:nth-child(3) {
    background: var(--code-dot-g);
  }

  .tv-code__name {
    font-family: var(--f-code);
    font-size: var(--fs-2xs);
    color: var(--code-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tv-code__copy {
    display: inline-flex;
    align-items: center;
    gap: var(--s-1h);
    height: var(--chip-h);
    padding: 0 var(--s-3);
    border: 1px solid var(--ink-line-strong);
    border-radius: var(--r-sm);
    background: var(--ftr-chip-bg);
    color: var(--ink-text-2);
    font-family: var(--f-code);
    font-size: var(--fs-3xs);
    transition: background-color var(--d-2), color var(--d-2), border-color var(--d-2);
  }

  .tv-code__copy:hover {
    background: var(--ftr-chip-bg-hover);
    color: var(--ftr-on-ink);
  }

  .tv-code__copy svg {
    width: var(--ico-xs);
    height: var(--ico-xs);
  }

  .tv-code__copy[data-copied="true"] {
    border-color: var(--ok);
    color: var(--ok-text);
  }

  .tv-code pre {
    padding: var(--s-5);
    overflow-x: auto;
    font-family: var(--f-code);
    font-size: var(--fs-xs);
    line-height: var(--lh-long);
    color: var(--code-text);
  }

  /* ================================================================ tema düğmesi */
  .tv-theme {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--btn-h-sm);
    height: var(--btn-h-sm);
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text-2);
    transition:
      border-color var(--d-2),
      color var(--d-2),
      background-color var(--d-2),
      transform var(--d-2) var(--ease-out);
  }

  .tv-theme:hover {
    border-color: var(--line-strong);
    color: var(--text);
    transform: translateY(var(--lift-sm));
  }

  .tv-theme svg {
    position: absolute;
    width: var(--ico-md);
    height: var(--ico-md);
    transition: transform var(--d-4) var(--ease-spring), opacity var(--d-2);
  }

  .tv-theme__sun {
    opacity: 0;
    transform: rotate(-90deg) scale(0.6);
  }

  .tv-theme__moon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
  }

  :root[data-theme="dark"] .tv-theme__sun {
    opacity: 1;
    transform: rotate(0deg) scale(1);
  }

  :root[data-theme="dark"] .tv-theme__moon {
    opacity: 0;
    transform: rotate(90deg) scale(0.6);
  }

  /* ================================================================ form girdileri */
  .tv-input,
  .tv-select {
    height: var(--btn-h-md);
    padding: 0 var(--s-4);
    border: 1px solid var(--line-2);
    border-radius: var(--r-md);
    background: var(--surface);
    color: var(--text);
    font-size: var(--fs-sm);
    transition: border-color var(--d-2), box-shadow var(--d-2);
  }

  .tv-input::placeholder {
    color: var(--text-3);
  }

  .tv-input:focus-visible,
  .tv-select:focus-visible {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--ring);
  }

  /* ================================================================ sayfa yolu (breadcrumb) */
  .tv-crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-2);
    margin-bottom: var(--s-5);
    font-size: var(--fs-xs);
    color: var(--text-3);
  }

  .tv-crumbs a {
    color: var(--text-2);
    transition: color var(--d-2);
  }

  .tv-crumbs a:hover {
    color: var(--brand-text);
  }

  .tv-crumbs__sep {
    color: var(--line-strong);
  }

  /* ================================================================ şablon kartı */
  .tv-tpl-card {
    padding: 0;
    gap: 0;
    overflow: hidden;
  }

  .tv-tpl-card__media {
    position: relative;
    aspect-ratio: 16 / 10;
    background: var(--surface-2);
    border-bottom: 1px solid var(--card-line);
    overflow: hidden;
  }

  .tv-tpl-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    transition: transform var(--d-4) var(--ease-out);
  }

  .tv-tpl-card:hover .tv-tpl-card__media img {
    transform: scale(1.03);
  }

  .tv-tpl-card__body {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    padding: var(--s-5) var(--s-6) var(--s-6);
    flex: 1 1 auto;
  }

  .tv-tpl-card__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2);
  }

  .tv-tpl-card__price {
    font-family: var(--f-display);
    font-size: var(--fs-h4);
    font-weight: var(--w-bold);
    color: var(--text);
  }

  .tv-tpl-card__actions {
    margin-top: auto;
    padding-top: var(--s-3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
  }

  /* ================================================================ boş durum */
  .tv-empty {
    display: grid;
    justify-items: center;
    text-align: center;
    gap: var(--s-4);
    padding: var(--s-10) var(--s-6);
    border: 1px solid var(--card-line);
    border-radius: var(--r-xl);
    background: var(--card-bg);
    box-shadow: var(--card-sh);
  }

  .tv-empty__desc {
    max-width: 54ch;
    font-size: var(--fs-sm);
    color: var(--text-2);
    line-height: var(--lh-long);
  }

  .tv-empty__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--s-3);
    margin-top: var(--s-2);
  }

  /* ================================================================ toast */
  .tv-toast {
    position: fixed;
    right: var(--s-5);
    bottom: var(--s-5);
    z-index: var(--z-toast);
    padding: var(--s-3) var(--s-4);
    border: 1px solid var(--ink-line-strong);
    border-radius: var(--r-md);
    background: var(--toast-bg);
    color: var(--toast-fg);
    font-size: var(--fs-xs);
    font-weight: var(--w-med);
    box-shadow: var(--sh-3);
    opacity: 0;
    transform: translateY(var(--s-3));
    pointer-events: none;
    transition: opacity var(--d-2) var(--ease-soft), transform var(--d-3) var(--ease-out);
  }

  .tv-toast[data-show="true"] {
    opacity: 1;
    transform: translateY(0);
  }
}
