/* VAR KADİM (Var-Asistan) — AI sohbet widget stilleri.
 * var-akis paterni: paylasilan index-dashboard-defer.css ten ayrildi → init te lazy yuklenir (loader.js ensureVarKadimStylesheet).
 * NOT: .guest-register-cta defer.css te KALDI (guest header bar ile paylasimli). */

/* Var-Asistan: veliye WhatsApp ile paylaşım */
.whatsapp-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: #25d366;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
  font-size: 14px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.whatsapp-btn:hover {
  background-color: #128c7e;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.whatsapp-icon {
  font-size: 18px;
}

/* =========================================
   V9.2.3 ASİSTAN İSKELETİ (JS'DEN TAŞINDI)
   ========================================= */

@keyframes ai-fab-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@media (prefers-reduced-motion: reduce) {
  #ai-chat-fab {
    animation: none !important;
  }
}

#ai-chat-wrapper {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  z-index: 120;
}

#ai-chat-fab {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(145deg, #1e40af 0%, #2563eb 45%, #3b82f6 100%);
  color: #f8fafc;
  border: 2px solid rgba(226, 232, 240, 0.85);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  z-index: 9999;
  box-shadow:
    0 0 20px rgba(148, 163, 184, 0.25),
    0 6px 22px rgba(15, 23, 42, 0.45);
  transition: transform 0.28s ease, border-color 0.28s ease, filter 0.28s ease;
  will-change: transform;
  animation: ai-fab-pulse 2.6s ease-in-out infinite;
}

#ai-chat-fab:hover {
  transform: scale(1.1);
  border-color: #f1f5f9;
  filter: brightness(1.06);
}

#ai-chat-fab:focus-visible {
  outline: 2px solid #e2e8f0;
  outline-offset: 3px;
}

#ai-chat-window {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(320px, calc(100vw - 32px));
  max-height: min(440px, 72vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  border-radius: 16px;
  border: 1px solid rgba(226, 232, 240, 0.22);
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

@media (max-width: 768px) {
  #ai-chat-window {
    right: -10px;
  }
}

#ai-chat-window.hidden {
  display: none !important;
}

.ai-chat-header {
  background: linear-gradient(120deg, #475569 0%, #94a3b8 35%, #e2e8f0 55%, #94a3b8 75%, #334155 100%);
  color: #0f172a;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: 0.02em;
  border-bottom: 1px solid rgba(15, 23, 42, 0.12);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.ai-chat-header span {
  display: flex;
  align-items: center;
  gap: 8px;
}

#close-ai-chat {
  background: rgba(15, 23, 42, 0.12);
  border: 1px solid rgba(15, 23, 42, 0.2);
  color: #0f172a;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

#close-ai-chat:hover {
  background: rgba(15, 23, 42, 0.2);
}

#ai-chat-messages {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  min-height: 260px;
  max-height: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(2, 6, 23, 0.25);
}

.ai-chat-input-area {
  padding: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(15, 23, 42, 0.35);
}

.ai-hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

#ai-upload-btn {
  flex-shrink: 0;
  background: rgba(148, 163, 184, 0.22);
  color: #e2e8f0;
  border: 1px solid rgba(226, 232, 240, 0.25);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
}

#ai-upload-btn:hover {
  background: rgba(96, 165, 250, 0.25);
  transform: scale(1.05);
}

#ai-user-input {
  flex: 1;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 22px;
  padding: 10px 16px;
  outline: none;
  font-size: 0.9rem;
  background: rgba(15, 23, 42, 0.55);
  color: #f1f5f9;
}

#ai-user-input::placeholder {
  color: #94a3b8;
}

#ai-user-input:focus {
  border-color: rgba(96, 165, 250, 0.65);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

#send-ai-msg {
  flex-shrink: 0;
  background: linear-gradient(145deg, #1e40af, #3b82f6);
  color: #fff;
  border: 1px solid rgba(226, 232, 240, 0.35);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 10px rgba(30, 64, 175, 0.4);
}

#send-ai-msg:hover {
  transform: scale(1.06);
}

/* =========================================
   V9.2.2 DENEYİM USTASI - ASİSTAN BALONLARI (TEMİZLENDİ)
   ========================================= */

#ai-chat-messages .ai-msg {
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  word-break: break-word;
  box-sizing: border-box;
}

/* Kullanıcının mesajı */
.user-message {
  background: linear-gradient(135deg, #0d6efd, #0a58ca);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 10px rgba(13, 110, 253, 0.2);
  transition: all 0.3s ease;
  padding: 10px 14px;
  align-self: flex-end;
  max-width: 85%;
}

/* Yapay zekâ / asistan mesajı */
.ai-message,
.bot-message {
  background-color: rgba(255, 255, 255, 0.05);
  border-left: 3px solid #0d6efd;
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
  color: #e2e8f0;
  padding: 10px 14px;
  align-self: flex-start;
  max-width: 85%;
}

.ai-msg-body {
  color: inherit;
}

/* 4. Yazıyor⬦ göstergesi (ileride .typing-indicator ile kullanılabilir) */
.typing-indicator {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    opacity: 0.5;
    transform: scale(0.98);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0.5;
    transform: scale(0.98);
  }
}

/* kadim.html (bağımsız sayfa) — gömülü sohbet (FAB-relative absolute yerine akordiyon içinde) + akordiyon menü. */
body.kadim-page #ai-chat-fab { display: none; }
body.kadim-page #close-ai-chat { display: none; }
body.kadim-page #ai-chat-wrapper { display: block; width: 100%; }
body.kadim-page #ai-chat-window {
  position: static;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  max-height: min(560px, 70vh);
}
body.kadim-page #ai-chat-window.hidden { display: flex !important; }

/* kadim.html — gündüz modunda gömülü sohbet penceresi (yalnız bu sayfaya scope'lu;
 * diğer sayfalardaki FAB popover widget'ı etkilenmez). */
body.kadim-page.beyaz-mod #ai-chat-window {
  background: var(--m-bg-card, #fff);
  border-color: var(--m-border-soft, rgba(15, 23, 42, 0.12));
}
body.kadim-page.beyaz-mod #ai-chat-messages {
  background: var(--m-bg-panel, #f8fafc);
}
body.kadim-page.beyaz-mod .ai-chat-input-area {
  background: var(--m-bg-panel, #f1f5f9);
  border-top-color: var(--m-border-subtle, rgba(15, 23, 42, 0.1));
}
body.kadim-page.beyaz-mod #ai-user-input {
  background: var(--m-bg-panel-light, #fff);
  color: var(--m-text-primary, #0f172a);
  border-color: var(--m-border-soft, rgba(15, 23, 42, 0.18));
}
body.kadim-page.beyaz-mod #ai-user-input::placeholder {
  color: var(--m-text-muted, #64748b);
}
body.kadim-page.beyaz-mod .ai-message,
body.kadim-page.beyaz-mod .bot-message {
  background: var(--m-bg-panel, rgba(15, 23, 42, 0.04));
  color: var(--m-text-primary, #0f172a);
}

.kadim-accordion {
  border: 1px solid var(--m-border-subtle, rgba(148, 163, 184, 0.25));
  border-radius: 12px;
  margin-bottom: 12px;
  background: var(--m-bg-panel, rgba(15, 23, 42, 0.35));
  overflow: hidden;
}
.kadim-accordion > summary {
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 600;
  color: var(--m-text-primary, #e2e8f0);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.kadim-accordion > summary::-webkit-details-marker { display: none; }
.kadim-accordion[open] > summary { border-bottom: 1px solid var(--m-border-subtle, rgba(148, 163, 184, 0.2)); }
.kadim-accordion-body { padding: 16px; }

/* kadim.html — Premium gate ekranı (Parça-4): free öğrenci kadim.html'e gelince. */
.kadim-premium-gate {
  max-width: 480px;
  margin: 40px auto;
  text-align: center;
  padding: 32px 24px;
  border: 1px solid var(--m-border-subtle, rgba(148, 163, 184, 0.25));
  border-radius: 16px;
  background: var(--m-bg-card, rgba(15, 23, 42, 0.5));
}
.kadim-premium-gate-icon { font-size: 42px; margin-bottom: 12px; }
.kadim-premium-gate h1 { font-size: 1.4rem; margin: 0 0 12px; color: var(--m-text-primary, #e2e8f0); }
.kadim-premium-gate p { color: var(--m-text-secondary, #cbd5e1); line-height: 1.5; margin: 0 0 16px; }
.kadim-premium-gate-note { font-size: 0.82rem; opacity: 0.8; margin-top: 16px; }
.kadim-premium-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 8px auto 0;
  padding: 12px 22px;
  border-radius: 12px;
  background: linear-gradient(145deg, #1e40af, #3b82f6);
  color: #f8fafc;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid rgba(226, 232, 240, 0.35);
  box-shadow: 0 4px 12px rgba(30, 64, 175, 0.35);
  cursor: pointer;
}
.kadim-premium-cta:hover { filter: brightness(1.08); }

/* kadim.html kökü: styles.css `.app{display:grid;grid-template-columns:260px 1fr}`
 * miras alır ama Kadim'in sol sidebar grid hücresi yok → içerik 260px'e sıkışırdı.
 * Standalone sayfa: full-genişlik dikey akış. */
body.kadim-page .app.kadim-root {
  display: flex;
  flex-direction: column;
  grid-template-columns: none;
}

/* kadim.html — sol bar + içerik (Yayınevi admin-sub-tab paterni)
 * Shell aktifken .content sarmalayıcısı full-bleed olur (max-width/padding sıfır)
 * → sol bar ekranın TAM soluna oturur, Yayınevi admin yerleşimi gibi. */
body.kadim-page .meydan-root .content:has(.kadim-shell:not([hidden])) {
  max-width: none;
  padding: 0;
}

body.kadim-page .kadim-shell {
  display: flex;
  gap: 0;
  align-items: stretch;
  min-height: calc(100dvh - 132px);
}

body.kadim-page .kadim-sidebar.admin-secondary-nav {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 0.75rem;
  border-right: 1px solid var(--m-border-subtle, rgba(148, 163, 184, 0.2));
  background: var(--m-bg-panel, rgba(15, 23, 42, 0.35));
  border-radius: 0;
}

body.kadim-page .kadim-sidebar .admin-sub-tab {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  font-size: 0.88rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--m-text-secondary, #94a3b8);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

body.kadim-page .kadim-sidebar .admin-sub-tab:hover {
  background: var(--m-bg-panel-light, rgba(148, 163, 184, 0.12));
  color: var(--m-text-primary, #f8fafc);
}

body.kadim-page .kadim-sidebar .admin-sub-tab.is-active {
  background: var(--m-purple-22, rgba(139, 92, 246, 0.22));
  color: var(--m-accent-purple, #e9d5ff);
  border-left: 3px solid var(--m-accent-purple, #8b5cf6);
}

body.kadim-page .kadim-shell-main {
  flex: 1;
  min-width: 0;
  padding: 1.5rem 24px;
}

/* VAR KADİM (AI) paneli — okunabilir genişlikte ortala. */
body.kadim-page #kadimPanel-kadim {
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}

body.kadim-page .kadim-panel[hidden] {
  display: none !important;
}

/* VAR PUSULA paneli — orijinal pusula.html same-origin iframe (ARENA deseni, GED-142). */
body.kadim-page .kadim-pusula-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 100%;
  border: 0;
  background: var(--m-bg-dark, #0a0d18);
}

/* VAR PUSULA = tam sayfa takeover: panel viewport'u kaplar (topbar + footer dahil). */
body.kadim-page .kadim-shell.is-pusula .kadim-shell-main {
  padding: 0;
}
body.kadim-page .kadim-shell.is-pusula #kadimPanel-pusula {
  position: fixed;
  inset: 0;
  z-index: 60;
  margin: 0;
}

/* Geri tuşu artık pusula.html içinde (header) — iframe'den parent'a postMessage ile döner. */

@media (max-width: 720px) {
  body.kadim-page .kadim-shell {
    flex-direction: column;
    min-height: 0;
  }
  body.kadim-page .kadim-sidebar.admin-secondary-nav {
    flex: none;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--m-border-subtle, rgba(148, 163, 184, 0.2));
    border-radius: 0;
    padding: 0.5rem;
  }
  body.kadim-page .kadim-sidebar .admin-sub-tab {
    flex: 1 1 auto;
    justify-content: center;
  }
  body.kadim-page .kadim-shell-main {
    padding: 0.75rem 1rem;
  }
}

/* KADIM-KURUM AI kota dashboard (GED-396) */
.kadim-kurum-ai-dash {
  padding: var(--space-md, 16px);
  margin-top: var(--space-sm, 8px);
}
.kadim-kurum-ai-dash__title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}
.kadim-kurum-ai-dash__metric {
  margin-bottom: 0.75rem;
}
.kadim-kurum-ai-dash__label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted, #94a3b8);
  margin-bottom: 0.25rem;
}
.kadim-kurum-ai-dash__bar {
  height: 10px;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.15);
  overflow: hidden;
}
.kadim-kurum-ai-dash__fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.2s ease;
}
.kadim-kurum-ai-dash__fill--ok {
  background: var(--success, #22c55e);
}
.kadim-kurum-ai-dash__fill--warn {
  background: var(--warning, #f59e0b);
}
.kadim-kurum-ai-dash__fill--danger {
  background: var(--danger, #ef4444);
}
.kadim-kurum-ai-dash__value {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
}
.kadim-kurum-quota--compact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  align-items: center;
  font-size: 0.75rem;
  padding: 4px 8px;
  background: rgba(15, 23, 42, 0.06);
}
.kadim-kurum-quota__uid {
  opacity: 0.85;
}
