/* Fantasy Assistant arayüz katmanı: Pico CSS'in üstüne tasarım ve duyarlılık. */

:root {
  --app-bg: #f5f6fa;
  --app-surface: #ffffff;
  --app-surface-2: #f0f2f8;
  --app-border: #e2e5ee;
  --app-text: #1a2030;
  --app-muted: #5f6b82;
  --app-accent: #4f46e5;
  --app-accent-soft: #eceeff;
  --app-radius: 14px;
  --app-radius-sm: 10px;
  --app-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 18px rgba(16, 24, 40, .06);
  --app-good: hsl(142 55% 33%);
  --app-bad: hsl(0 68% 45%);
  --app-bar-h: 3.25rem;
}

/* Pico değişkenleri (açık tema) */
:root:not([data-theme="dark"]) {
  --pico-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --pico-background-color: var(--app-bg);
  --pico-color: var(--app-text);
  --pico-muted-color: var(--app-muted);
  --pico-primary: var(--app-accent);
  --pico-primary-background: var(--app-accent);
  --pico-primary-hover: #4338ca;
  --pico-primary-hover-background: #4338ca;
  --pico-primary-underline: rgba(79, 70, 229, .4);
  --pico-primary-focus: rgba(79, 70, 229, .25);
  --pico-card-background-color: var(--app-surface);
  --pico-card-border-color: var(--app-border);
  --pico-border-radius: var(--app-radius-sm);
  --pico-form-element-spacing-vertical: .6rem;
  --pico-form-element-spacing-horizontal: .8rem;
  --pico-block-spacing-vertical: 1rem;
  --pico-typography-spacing-vertical: .9rem;
  --pico-table-border-color: var(--app-border);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --app-bg: #0e1120;
    --app-surface: #161a2d;
    --app-surface-2: #1d2238;
    --app-border: #272d47;
    --app-text: #e7e9f4;
    --app-muted: #9aa4bc;
    --app-accent: #8b93ff;
    --app-accent-soft: #20264a;
    --app-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    --app-good: hsl(142 55% 55%);
    --app-bad: hsl(0 80% 68%);

    --pico-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --pico-background-color: var(--app-bg);
    --pico-color: var(--app-text);
    --pico-muted-color: var(--app-muted);
    --pico-primary: var(--app-accent);
    --pico-primary-background: #5b63f0;
    --pico-primary-hover: #a3a9ff;
    --pico-primary-hover-background: #6f76f5;
    --pico-primary-underline: rgba(139, 147, 255, .4);
    --pico-primary-focus: rgba(139, 147, 255, .3);
    --pico-card-background-color: var(--app-surface);
    --pico-card-border-color: var(--app-border);
    --pico-border-radius: var(--app-radius-sm);
    --pico-form-element-spacing-vertical: .6rem;
    --pico-form-element-spacing-horizontal: .8rem;
    --pico-form-element-background-color: var(--app-surface-2);
    --pico-form-element-border-color: var(--app-border);
    --pico-table-border-color: var(--app-border);
  }
}

:root[data-theme="dark"] {
    --app-bg: #0e1120;
    --app-surface: #161a2d;
    --app-surface-2: #1d2238;
    --app-border: #272d47;
    --app-text: #e7e9f4;
    --app-muted: #9aa4bc;
    --app-accent: #8b93ff;
    --app-accent-soft: #20264a;
    --app-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    --app-good: hsl(142 55% 55%);
    --app-bad: hsl(0 80% 68%);

    --pico-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --pico-background-color: var(--app-bg);
    --pico-color: var(--app-text);
    --pico-muted-color: var(--app-muted);
    --pico-primary: var(--app-accent);
    --pico-primary-background: #5b63f0;
    --pico-primary-hover: #a3a9ff;
    --pico-primary-hover-background: #6f76f5;
    --pico-primary-underline: rgba(139, 147, 255, .4);
    --pico-primary-focus: rgba(139, 147, 255, .3);
    --pico-card-background-color: var(--app-surface);
    --pico-card-border-color: var(--app-border);
    --pico-border-radius: var(--app-radius-sm);
    --pico-form-element-spacing-vertical: .6rem;
    --pico-form-element-spacing-horizontal: .8rem;
    --pico-form-element-background-color: var(--app-surface-2);
    --pico-form-element-border-color: var(--app-border);
    --pico-table-border-color: var(--app-border);
  }

body { background: var(--app-bg); -webkit-text-size-adjust: 100%; }
main.container { max-width: 1280px; padding: 0 1rem 3rem; }
h1 { font-size: 1.6rem; font-weight: 750; letter-spacing: -.02em; margin: 1.25rem 0 1rem; }
h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; margin-top: 1.25rem; }
small, .muted { color: var(--app-muted); }

/* ---------- Üst çubuk ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  margin: 0 -1rem 1rem; padding: 0 1rem;
  background: color-mix(in srgb, var(--app-surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--app-border);
}
.appbar-in { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; max-width: 1280px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: .55rem; height: var(--app-bar-h); font-weight: 750; letter-spacing: -.01em; color: var(--app-text); text-decoration: none; }
.brand::before { content: ""; width: 1.35rem; height: 1.35rem; border-radius: 7px; background: linear-gradient(135deg, var(--app-accent), #a78bfa); box-shadow: 0 2px 8px rgba(79, 70, 229, .35); }
.appbar form.logout { margin: 0 0 0 auto; order: 2; }
.appbar form.logout button { margin: 0; width: auto; padding: .35rem .8rem; font-size: .85rem; }
.tabs {
  display: flex; gap: .25rem; order: 3; flex: 1 0 100%;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  padding: .15rem 0 .55rem; margin: 0;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: 0 0 auto; padding: .4rem .8rem; border-radius: 999px; font-size: .9rem; font-weight: 600;
  color: var(--app-muted); text-decoration: none; white-space: nowrap; transition: background .15s, color .15s;
}
.tabs a:hover { background: var(--app-surface-2); color: var(--app-text); }
.tabs a[aria-current="page"] { background: var(--app-accent-soft); color: var(--app-accent); }
@media (min-width: 900px) {
  .tabs { order: 1; flex: 1 1 auto; padding: 0; justify-content: flex-start; }
  .appbar form.logout { order: 2; margin-left: 0; }
  .appbar-in { flex-wrap: nowrap; gap: 1rem; }
}

/* ---------- Kartlar ve formlar ---------- */
article {
  background: var(--app-surface); border: 1px solid var(--app-border); border-radius: var(--app-radius);
  box-shadow: var(--app-shadow); padding: 1rem 1.1rem; margin: 0 0 1rem;
}
article > header, article > footer { background: transparent; border: 0; margin: 0 0 .5rem; padding: 0; }
form.filters, #strengths > .grid {
  background: var(--app-surface); border: 1px solid var(--app-border); border-radius: var(--app-radius);
  box-shadow: var(--app-shadow); padding: .9rem 1rem .4rem; margin-bottom: 1rem;
}
#strengths > .grid { gap: .75rem; padding-bottom: .2rem; }
#strengths > .grid form { margin: 0; }
.grid { gap: .75rem 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); }
label { font-size: .82rem; font-weight: 600; color: var(--app-muted); }
label input:not([type="checkbox"]):not([type="radio"]), label select { margin-top: .3rem; font-size: .95rem; font-weight: 400; color: var(--app-text); }
input:not([type="checkbox"]):not([type="radio"]), select { margin-bottom: .75rem; }
fieldset { margin-bottom: .75rem; }
legend { font-size: .82rem; font-weight: 700; color: var(--app-muted); padding: 0; margin-bottom: .35rem; }
button, [type="submit"] { border-radius: var(--app-radius-sm); font-weight: 650; }
form.filters > button[type="submit"], #suggest form > button[type="submit"], #dropadd form > button[type="submit"], #trade form > button[type="submit"] { margin-bottom: .75rem; }
@media (max-width: 575px) {
  form.filters button[type="submit"], #suggest form > button, #dropadd form > button, #trade form > button { width: 100%; }
}
/* Kategori / gösterim seçenekleri çip gibi görünür */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0; border: 0; margin-bottom: .5rem; }
.chips legend { width: 100%; }
.chips label { display: inline-flex; align-items: center; gap: .35rem; margin: 0; padding: .3rem .65rem; border: 1px solid var(--app-border); border-radius: 999px; background: var(--app-surface-2); color: var(--app-text); font-size: .85rem; font-weight: 600; cursor: pointer; }
.chips input { margin: 0; width: 1rem; height: 1rem; }

/* ---------- Tablolar ---------- */
.table-scroll {
  overflow: auto; max-width: 100%; max-height: 75vh; margin-bottom: 1rem;
  background: var(--app-surface); border: 1px solid var(--app-border); border-radius: var(--app-radius); box-shadow: var(--app-shadow);
  -webkit-overflow-scrolling: touch;
}
.table-scroll table { margin: 0; font-size: .88rem; border-collapse: separate; border-spacing: 0; width: 100%; }
.table-scroll th, .table-scroll td { padding: .45rem .6rem; border-bottom: 1px solid var(--app-border); white-space: nowrap; }
.table-scroll thead th { position: sticky; top: 0; z-index: 2; background: var(--app-surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.table-scroll thead th a { color: inherit; text-decoration: none; }
.table-scroll tbody th[scope="row"] { position: sticky; left: 0; z-index: 1; background: var(--app-surface); text-align: left; font-weight: 650; box-shadow: 1px 0 0 var(--app-border); }
.table-scroll thead th:first-child { left: 0; z-index: 3; }
.table-scroll tbody tr:last-child > * { border-bottom: 0; }
.table-scroll td strong { font-weight: 750; }
.table-scroll td small { opacity: .8; }
@media (max-width: 575px) {
  .table-scroll { margin-left: -1rem; margin-right: -1rem; max-width: none; border-radius: 0; border-left: 0; border-right: 0; }
  .table-scroll table { font-size: .8rem; }
  .table-scroll th, .table-scroll td { padding: .4rem .5rem; }
}
article table { margin-bottom: 0; }
article table th, article table td { padding: .4rem .5rem; }

/* ---------- Sayfa bileşenleri ---------- */
.advice { gap: .75rem; }
.advice article { border-radius: var(--app-radius); box-shadow: none; padding: .8rem .95rem; }
.suggest-cards, .dropadd-cards { grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)) !important; }
.trade-panels { grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)) !important; }
.suggest-card, .dropadd-card { display: flex; flex-direction: column; }
.suggest-card header, .dropadd-card header { font-size: 1.02rem; }
.suggest-card small, .dropadd-card small { font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: .72rem; color: var(--app-muted); }
.suggest-card ul, .dropadd-card ul { list-style: none; padding-left: 0 !important; display: flex; flex-wrap: wrap; gap: .3rem; margin: .25rem 0 .6rem !important; }
.suggest-card li, .dropadd-card li { padding: .2rem .55rem; border-radius: 999px; background: var(--app-surface-2); font-size: .82rem; font-weight: 600; margin: 0; }
.suggest-card li::marker, .dropadd-card li::marker { content: ""; }
.suggest-card > a:last-child { margin-top: auto; font-weight: 650; }
.dropadd-card .dropadd-worse { text-transform: none; letter-spacing: 0; font-weight: 500; }
.trade-players { border: 1px solid var(--app-border); border-radius: var(--app-radius-sm); padding: .7rem .8rem; background: var(--app-surface-2); }
.trade-players label { color: var(--app-text); font-weight: 500; font-size: .9rem; }
.trade-error { color: var(--app-bad); font-weight: 600; }
.flash { padding: .7rem 1rem; }

/* Giriş sayfası */
.login-wrap { max-width: 26rem; margin: 14vh auto 0; }
.login-wrap article { padding: 1.4rem; }
.login-wrap h1 { margin-top: 0; }

pre { border-radius: var(--app-radius-sm); }

/* Sıralama tablosu: sıra ve oyuncu sütunları yapışkan */
.has-rank tbody td:first-child { position: sticky; left: 0; z-index: 1; background: var(--app-surface); min-width: 2.6rem; text-align: center; font-weight: 700; color: var(--app-muted); }
.has-rank tbody th[scope="row"] { left: 2.6rem; }
.has-rank thead th:nth-child(2) { left: 2.6rem; z-index: 3; }
.has-rank tbody th[scope="row"] small { display: block; font-weight: 500; color: var(--app-muted); }

/* Takas oyuncu listeleri ve filtre ızgaraları */
.trade-players { padding-top: .9rem; }
.trade-players legend { padding: 0 .35rem; margin-bottom: .2rem; }
#rankings-controls .grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr)); }

/* Takas listesi başlığı kutunun içinde kalsın */
.trade-players { padding-top: .6rem; }
.trade-players legend { float: left; width: 100%; padding: 0; margin: 0 0 .35rem; }
.trade-players legend + * { clear: both; }

/* Dar ekranda sabit sütunlar daha az yer kaplasın */
@media (max-width: 575px) {
  .table-scroll tbody th[scope="row"] { white-space: normal; min-width: 6.5rem; max-width: 8.2rem; line-height: 1.25; }
  .table-scroll tbody th[scope="row"] small { display: block; }
  .has-rank tbody th[scope="row"] small { display: none; }
  .has-rank tbody td:first-child { min-width: 2.1rem; padding-left: .3rem; padding-right: .3rem; }
  .has-rank tbody th[scope="row"] { left: 2.1rem; }
  .has-rank thead th:nth-child(2) { left: 2.1rem; }
}

/* Pico, "input + small" kalıbını yardım metni sayar; takas listesinde satır içi kalsın */
.trade-players label small { display: inline; width: auto; margin: 0 0 0 .3rem; }
.trade-players label small:not(.trade-il) { color: var(--app-muted); font-size: .8rem; }
.trade-players label { line-height: 1.5; padding: .15rem 0; }
