/* Yapay zeka asistanı ve Ayarlar → Yapay zeka */

/* Kenar çubuğu: menü uzadığında alttaki öğeler (Ayarlar alt menüleri) ekran dışında kalmasın */
.sidebar { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.sidebar > .side-label:first-of-type { margin-top: 30px; }
.sidebar nav .nav-link { height: 40px; flex-shrink: 0; }
@media (max-height: 820px) {
  .sidebar { padding-top: 18px; padding-bottom: 14px; }
  .sidebar > .side-label:first-of-type { margin-top: 18px; }
  .sidebar nav { gap: 3px; }
  .sidebar nav .nav-link { height: 36px; }
  .sidebar nav .nav-group-label { margin: 14px 10px 4px; }
}

/* Kenar çubuğu: Ayarlar alt menüsü */
.nav-parent { display: flex; align-items: center; gap: 12px; padding: 8px 11px 4px; color: #6d7186; font-size: 14px; font-weight: 600; cursor: default; }
.sidebar nav .nav-link.nav-sublink { height: 36px; padding-left: 30px; font-size: 13px; }
.nav-sublink .nav-icon { font-size: 14px; }
@media (max-width: 760px) {
  .nav-parent { display: none; }
  .sidebar nav .nav-link.nav-sublink { padding-left: 0; font-size: 0; }
  .nav-sublink .nav-icon { font-size: 16px; }
}
.nav-ai-badge { margin-left: auto; padding: 2px 6px; border-radius: 10px; color: var(--purple); background: #efedff; font-size: 9.5px; font-weight: 700; letter-spacing: .3px; }

/* Sohbet düzeni: solda geçmiş, sağda sohbet */
.ai-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: stretch; }
.ai-layout.history-collapsed { grid-template-columns: 44px minmax(0, 1fr); }
.ai-history { display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 460px; padding: 0; overflow: hidden; }
.ai-history-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 12px 10px 16px; font-size: 13px; }
.ai-history-toggle { display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 8px; color: #6d7186; background: #fff; font-size: 15px; cursor: pointer; }
.ai-history-toggle:hover { color: var(--purple); border-color: #c9c3f7; }
.ai-history-search { margin: 0 12px 8px; padding: 7px 10px; border: 1px solid #e1e3ec; border-radius: 8px; outline: none; font: inherit; font-size: 12.5px; }
.ai-history-search:focus { border-color: #988ef0; }
.ai-history-list { flex: 1; overflow-y: auto; padding: 0 8px 10px; scrollbar-width: thin; }
.ai-history-group { margin: 10px 8px 4px; color: #a0a3b2; font-size: 10.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; }
.ai-history-item { position: relative; display: flex; align-items: center; gap: 4px; border-radius: 8px; }
.ai-history-item:hover, .ai-history-item.active { background: #f4f2ff; }
.ai-history-item.active .ai-history-open { color: var(--purple); font-weight: 600; }
.ai-history-open { flex: 1; min-width: 0; padding: 8px 8px; border: 0; color: var(--ink); background: none; font: inherit; font-size: 12.5px; text-align: left; cursor: pointer; }
.ai-history-open span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ai-history-open small { display: block; margin-top: 1px; color: #a0a3b2; font-size: 11px; }
.ai-history-tools { display: none; gap: 2px; padding-right: 4px; }
.ai-history-item:hover .ai-history-tools, .ai-history-item:focus-within .ai-history-tools { display: flex; }
.ai-history-tools button { display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 6px; color: #8a8ea0; background: none; font-size: 12px; cursor: pointer; }
.ai-history-tools button:hover { color: var(--purple); background: #fff; }
.ai-history-tools button[data-delete]:hover { color: #9c2f3d; }
.ai-history-empty { padding: 18px 10px; color: #a0a3b2; font-size: 12px; text-align: center; }
.ai-layout.history-collapsed .ai-history-head { padding: 12px 8px; justify-content: center; }
.ai-layout.history-collapsed .ai-history-head b, .ai-layout.history-collapsed .ai-history-search, .ai-layout.history-collapsed .ai-history-list { display: none; }
.ai-layout.history-collapsed .ai-history-toggle { transform: rotate(180deg); }
.ai-action.expired { opacity: .7; }

.ai-shell { display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 460px; padding: 0; overflow: hidden; }
.ai-scroll { flex: 1; overflow-y: auto; padding: 22px 22px 8px; }
.ai-welcome { max-width: 640px; margin: 28px auto; text-align: center; }
.ai-welcome-mark { display: inline-grid; place-items: center; width: 46px; height: 46px; margin-bottom: 12px; border-radius: 14px; color: #fff; background: linear-gradient(135deg, #7d6ff0, #5545c8); font-size: 21px; }
.ai-welcome h2 { margin: 0 0 6px; }
.ai-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
.ai-chip { padding: 8px 13px; border: 1px solid var(--line); border-radius: 18px; color: #4d5165; background: #fff; font: inherit; font-size: 12.5px; cursor: pointer; transition: border-color .15s, color .15s, background .15s; }
.ai-chip:hover { border-color: #c9c3f7; color: var(--purple); background: #f7f6ff; }

/* minmax(0, 1fr): geniş tablolar (nowrap) sütunu büyütüp tüm mesajları yatay taşırmasın; tablo kendi kutusunda kaysın */
.ai-messages { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; max-width: 980px; margin: 0 auto; }
.ai-msg { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.ai-bubble, .ai-action, .ai-notice { overflow-wrap: anywhere; }
.ai-msg.user { justify-content: flex-end; }
.ai-avatar { flex: 0 0 auto; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; color: #fff; background: linear-gradient(135deg, #7d6ff0, #5545c8); font-size: 13px; }
.ai-bubble { min-width: 0; max-width: 100%; font-size: 13.5px; line-height: 1.6; color: var(--ink); }
.ai-msg.assistant .ai-bubble { flex: 1; }
.ai-msg.user .ai-bubble { max-width: 75%; padding: 9px 14px; border-radius: 14px 14px 4px 14px; color: #fff; background: var(--purple); }
.ai-bubble p { margin: 0 0 8px; }
.ai-bubble p:last-child { margin-bottom: 0; }
.ai-bubble ul { margin: 4px 0 10px; padding-left: 20px; }
.ai-bubble code { padding: 1px 5px; border-radius: 4px; background: #f1f0fa; font-size: 12px; }
.ai-msg.user .ai-bubble code { background: #ffffff2e; }
.ai-error { color: #9c2f3d; }

.ai-typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.ai-typing i { width: 7px; height: 7px; border-radius: 50%; background: #b7b1ef; animation: ai-dot 1.2s infinite ease-in-out; }
.ai-typing i:nth-child(2) { animation-delay: .15s; }
.ai-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .ai-typing i { animation: none; opacity: .6; } }

.ai-result { margin-top: 12px; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: #fff; }
.ai-result-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafafe; font-size: 12.5px; }
.ai-result-head span { color: var(--muted); font-size: 12px; }
.ai-result .table-wrap { max-height: 420px; overflow: auto; }
.ai-result table { font-size: 12.5px; }

.ai-notice { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 14px; border: 1px solid #bfe6d3; border-radius: 10px; color: #1f5f45; background: #f3fbf7; font-size: 13px; }
.ai-notice a { margin-left: auto; color: var(--purple); font-weight: 600; text-decoration: none; white-space: nowrap; }
.ai-notice-icon { flex: 0 0 auto; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: #fff; background: var(--green); font-size: 11px; font-weight: 700; }
.ai-link { color: var(--purple); font-weight: 600; text-decoration: none; }
.ai-link:hover { text-decoration: underline; }
a.apollo-badge { text-decoration: none; }
.ai-warn { color: #b8742f; font-weight: 600; }
.ai-action-details { margin: 10px 0 0 32px !important; padding: 0 !important; list-style: none; display: grid; gap: 3px; color: #5d5140; font-size: 12.5px; }
.ai-action-details li::before { content: '• '; color: #e09a45; }
.ai-action { margin-top: 12px; padding: 14px; border: 1px solid #f3dcc0; border-radius: 11px; background: #fffaf3; }
.ai-action.applied { border-color: #bfe6d3; background: #f3fbf7; }
.ai-action.cancelled { opacity: .7; }
.ai-action-head { display: flex; gap: 10px; align-items: flex-start; }
.ai-action-head p { margin: 2px 0 0; color: #6b5a44; font-size: 12.5px; }
.ai-action-icon { flex: 0 0 auto; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: #fff; background: #e09a45; font-size: 12px; font-weight: 700; }
.ai-action.applied .ai-action-icon { background: var(--green); }
.ai-action-sample { margin: 10px 0 0 32px !important; padding: 0 !important; list-style: none; display: grid; gap: 4px; font-size: 12.5px; }
.ai-action-sample small { color: var(--muted); }
.ai-action-sample .status-badge { margin-left: 4px; }
.ai-action-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.ai-action-result { margin-top: 10px; color: #7d5525; font-size: 12.5px; font-weight: 600; }
.ai-action-result.ok { color: #1f7a56; }

.ai-composer { display: flex; gap: 10px; align-items: flex-end; padding: 14px 18px; border-top: 1px solid var(--line); background: #fff; }
.ai-composer textarea { flex: 1; min-height: 42px; max-height: 180px; padding: 10px 13px; border: 1px solid #e1e3ec; border-radius: 10px; outline: none; color: var(--ink); background: #fff; font: inherit; font-size: 13.5px; line-height: 1.5; resize: none; }
.ai-composer textarea:focus { border-color: #988ef0; box-shadow: 0 0 0 3px #7162df14; }
.ai-composer .button { height: 42px; }
.ai-composer .ai-mic { width: 42px; padding: 0; display: inline-flex; align-items: center; justify-content: center; color: var(--purple); }
.ai-composer .ai-mic.hidden { display: none; }
.ai-composer .ai-mic.listening { color: #fff; background: #d64545; border-color: #d64545; animation: ai-mic-pulse 1.2s ease-in-out infinite; }
.ai-composer textarea.listening { border-color: #d64545; box-shadow: 0 0 0 3px #d6454514; }
@keyframes ai-mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 #d6454566; } 50% { box-shadow: 0 0 0 6px #d6454500; } }
@media (prefers-reduced-motion: reduce) { .ai-composer .ai-mic.listening { animation: none; } }
.ai-foot { padding: 0 18px 12px; color: #a0a3b2; font-size: 11px; text-align: center; background: #fff; }
.ai-model-pill { padding: 4px 9px; border-radius: 12px; color: var(--purple); background: #f1effe; font-size: 11.5px; font-weight: 600; }

/* Ayarlar → Yapay zeka: sağlayıcı seçimi */
.ai-enabled-row { margin-top: 4px !important; }
.ai-active-pill { display: none; margin-left: 6px; padding: 3px 8px; border-radius: 10px; color: #24966a; background: #eaf8f1; font-size: 10.5px; font-weight: 700; vertical-align: middle; }
.ai-provider-panel { transition: opacity .15s; }
.ai-provider-panel.active { border-color: #d8d3fb; box-shadow: 0 0 0 3px #7162df0f; }
.ai-provider-panel.active .ai-active-pill { display: inline-block; }
.ai-provider-panel:not(.active) { opacity: .78; }
.ai-provider-panel .form-actions { margin-top: 16px; }
.ai-save-bar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.ai-save-bar .field-hint { margin-right: auto; }

@media (max-width: 980px) {
  .ai-layout, .ai-layout.history-collapsed { grid-template-columns: minmax(0, 1fr); }
  .ai-history { height: auto; min-height: 0; max-height: 260px; }
  .ai-layout.history-collapsed .ai-history { max-height: none; }
  .ai-layout.history-collapsed .ai-history-head { justify-content: space-between; padding: 12px 16px; }
  .ai-layout.history-collapsed .ai-history-head b { display: inline; }
  .ai-history-tools { display: flex; }
}
@media (max-width: 760px) {
  .ai-shell { height: calc(100vh - 170px); }
  .ai-scroll { padding: 14px 12px 6px; }
  .ai-msg.user .ai-bubble { max-width: 90%; }
}
