/* AI Rapor Asistanı — Raporlar sayfasının üst paneli.
   styles.css'teki tema değişkenlerini kullanır (açık/koyu tema otomatik). */

.ai-panel {
  position: relative;
  overflow: hidden;
  padding: 24px;
  background:
    radial-gradient(120% 140% at 100% 0%, var(--brand-soft) 0%, transparent 55%),
    var(--surface);
}
.ai-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}

/* Başlık */
.ai-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ai-title { display: flex; align-items: center; gap: 14px; }
.ai-mark {
  width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 22px; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  box-shadow: 0 8px 20px -8px var(--brand);
}
.ai-title h3 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.ai-title p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.ai-usage { min-width: 200px; text-align: right; }
.ai-usage-text { font-size: 12px; color: var(--muted); }
.ai-usage-text strong { color: var(--text); font-variant-numeric: tabular-nums; }
.ai-meter { margin-top: 6px; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.ai-meter span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--accent)); transition: width .4s ease; }
.ai-meter.is-low span { background: var(--warn); }
.ai-link { margin-top: 8px; padding: 0; border: 0; background: none; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; color: var(--brand); }
.ai-link:hover { text-decoration: underline; }

/* Soru çubuğu */
.ai-ask { margin-top: 20px; }
.ai-ask-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 16px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line-strong);
  transition: border-color .15s, box-shadow .15s;
}
.ai-ask-bar:focus-within { border-color: var(--brand); box-shadow: var(--ring); }
.ai-ask-bar .ai-ask-icon { color: var(--brand); font-size: 18px; flex-shrink: 0; }
.ai-ask-bar input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 15px; padding: 10px 0;
}
.ai-ask-bar input::placeholder { color: var(--faint); }
.ai-send {
  flex-shrink: 0; height: 42px; padding: 0 20px; border: 0; border-radius: 999px; cursor: pointer;
  font: inherit; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  transition: transform .1s, filter .15s, opacity .15s;
}
.ai-send:hover { filter: brightness(1.08); }
.ai-send:active { transform: translateY(1px); }
.ai-send:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.ai-ask-hint { margin: 8px 4px 0; font-size: 12px; color: var(--faint); }
.ai-disabled-note {
  margin-top: 8px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--warn-soft); color: var(--text); font-size: 13px;
}

/* Hazır soru kartları */
.ai-groups { margin-top: 22px; display: grid; gap: 18px; }
.ai-group-title {
  display: flex; align-items: center; gap: 8px; margin: 0 0 10px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.ai-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.ai-card {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left; cursor: pointer;
  padding: 14px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit;
  transition: border-color .15s, transform .15s, box-shadow .15s, background .15s;
}
.ai-card:hover { border-color: var(--brand); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.ai-card:focus-visible { outline: 0; box-shadow: var(--ring); border-color: var(--brand); }
.ai-card.is-active { border-color: var(--brand); background: var(--brand-soft); }
.ai-card-icon {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 16px;
  background: var(--surface-3); color: var(--brand);
}
.ai-card[data-group="faults"] .ai-card-icon { background: var(--danger-soft); color: var(--danger); }
.ai-card[data-group="maintenance"] .ai-card-icon { background: var(--warn-soft); color: var(--warn); }
.ai-card[data-group="staff"] .ai-card-icon { background: var(--good-soft); color: var(--good); }
.ai-card strong { display: block; font-size: 14px; line-height: 1.3; }
.ai-card small { display: block; margin-top: 3px; font-size: 12px; line-height: 1.35; color: var(--muted); }

/* Sonuç */
#ai-result:empty { display: none; }
#ai-result { margin-top: 22px; }
.ai-answer {
  position: relative; padding: 18px 20px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  animation: ai-in .35s ease both;
}
.ai-answer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ai-answer-q { margin: 0; font-size: 13px; color: var(--muted); font-weight: 600; }
.ai-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  background: var(--brand-soft); color: var(--brand);
}
.ai-badge.is-preset { background: var(--surface-3); color: var(--muted); }
.ai-answer-text { margin: 10px 0 0; font-size: 16px; line-height: 1.55; color: var(--text); }
.ai-answer-foot { margin: 10px 0 0; font-size: 12px; color: var(--faint); }

.ai-visuals { margin-top: 14px; display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.ai-chart-card { padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); animation: ai-in .4s ease both; }
.ai-chart-card h4 { margin: 0 0 12px; font-size: 13px; color: var(--muted); font-weight: 700; }
.ai-table { margin-top: 14px; animation: ai-in .45s ease both; }
.ai-table .panel { margin: 0; }
.ai-note {
  margin-top: 12px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--muted); font-size: 13px;
}
.ai-empty { margin-top: 14px; padding: 22px; text-align: center; border-radius: var(--radius); border: 1px dashed var(--line-strong); color: var(--muted); }

.ai-error {
  padding: 14px 16px; border-radius: var(--radius); background: var(--danger-soft);
  color: var(--text); border-left: 4px solid var(--danger); font-size: 14px;
}

/* Yükleniyor */
.ai-loading { padding: 18px 20px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.ai-loading-label { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); font-weight: 600; }
.ai-dots { display: inline-flex; gap: 4px; }
.ai-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); animation: ai-dot 1s infinite ease-in-out; }
.ai-dots i:nth-child(2) { animation-delay: .15s; }
.ai-dots i:nth-child(3) { animation-delay: .3s; }
.ai-skel { margin-top: 12px; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-3) 25%, var(--line) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: ai-shimmer 1.2s infinite linear; }
.ai-skel.w80 { width: 80%; } .ai-skel.w60 { width: 60%; } .ai-skel.w40 { width: 40%; }

@keyframes ai-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes ai-dot { 0%, 80%, 100% { transform: scale(.6); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }
@keyframes ai-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (max-width: 640px) {
  .ai-panel { padding: 18px; }
  .ai-usage { text-align: left; min-width: 0; width: 100%; }
  .ai-send { padding: 0 14px; }
  .ai-visuals { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .ai-answer, .ai-chart-card, .ai-table { animation: none; }
  .ai-dots i, .ai-skel { animation: none; }
}
