/* Yerel Excel - Yapay Zekâ Paneli */
.hdr-btn.active { background: rgba(255,255,255,.28); }
.hdr-btn.ai-btn { background: linear-gradient(135deg, #7c3aed, #2563eb); font-weight: 700; box-shadow: 0 2px 8px rgba(37,99,235,.35); }
.hdr-btn.ai-btn:hover { filter: brightness(1.08); }
.ai-dock { position: relative; width: 400px; min-width: 320px; max-width: 720px; flex-direction: column; background: #fff; border-left: 1px solid var(--excel-border-color); box-shadow: -6px 0 18px rgba(0,0,0,.08); z-index: 30; flex: none; }
.ai-resize { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; cursor: ew-resize; z-index: 5; }
.ai-resize:hover { background: rgba(37,99,235,.25); }
.ai-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: linear-gradient(135deg, #1e3a8a, #6d28d9); color: #fff; }
.ai-title { display: flex; gap: 10px; align-items: center; }
.ai-title b { display: block; font-size: 14px; }
.ai-title small { display: block; font-size: 11px; opacity: .85; }
.ai-title small.on { color: #86efac; opacity: 1; }
.ai-spark { font-size: 20px; }
.ai-head-btns { display: flex; gap: 4px; }
.ai-head-btns button { background: rgba(255,255,255,.15); border: 0; color: #fff; width: 28px; height: 28px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.ai-head-btns button:hover { background: rgba(255,255,255,.3); }
.ai-ctxbar { padding: 6px 12px; font-size: 11.5px; background: #f5f3ff; border-bottom: 1px solid #e5e7eb; color: #475569; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-priv { color: #b45309; }
.ai-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ai-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: #fafafa; user-select: text; }
.ai-msgs * { user-select: text; -webkit-user-select: text; }
.ai-msg { display: flex; flex-direction: column; gap: 6px; max-width: 94%; }
.ai-msg.user { align-self: flex-end; align-items: flex-end; }
.ai-msg.assistant { align-self: flex-start; }
.ai-bubble { padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height: 1.5; word-break: break-word; }
.ai-msg.user .ai-bubble { background: #2563eb; color: #fff; border-bottom-right-radius: 3px; }
.ai-msg.assistant .ai-bubble { background: #fff; border: 1px solid #e5e7eb; border-bottom-left-radius: 3px; }
.ai-bubble code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.ai-bubble pre { background: #0f172a; color: #e2e8f0; padding: 8px; border-radius: 6px; overflow-x: auto; font-size: 11.5px; margin: 4px 0; }
.ai-bubble ul { margin: 4px 0 4px 18px; }
.ai-typing { display: flex; gap: 4px; padding: 12px 14px; }
.ai-typing span { width: 7px; height: 7px; background: #94a3b8; border-radius: 50%; animation: aiBlink 1.2s infinite; }
.ai-typing span:nth-child(2) { animation-delay: .2s; } .ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes aiBlink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }
.ai-actions { background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 10px; padding: 8px 10px; }
.ai-actions.applied { background: #ecfdf5; border-color: #a7f3d0; }
.ai-actions.rejected { background: #f3f4f6; border-color: #e5e7eb; opacity: .7; }
.ai-actions-h { font-weight: 700; font-size: 12px; margin-bottom: 4px; color: #3730a3; }
.ai-actions ol { margin: 0 0 6px 18px; font-size: 12px; line-height: 1.55; color: #334155; }
.ai-act-btns { display: flex; gap: 6px; align-items: center; }
.ai-act-btns button, .ai-btnrow button { border: 1px solid #cbd5e1; background: #fff; border-radius: 6px; padding: 5px 12px; cursor: pointer; font-size: 12px; font-family: inherit; }
.ai-act-btns button.pri, .ai-btnrow button.pri { background: #107c41; border-color: #107c41; color: #fff; font-weight: 600; }
.ai-ok { color: #047857; font-weight: 600; font-size: 12px; } .ai-muted { color: #64748b; font-size: 12px; }
.ai-foot { border-top: 1px solid #e5e7eb; padding: 8px 10px 10px; background: #fff; }
.ai-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.ai-chip { flex: none; border: 1px solid #ddd6fe; background: #f5f3ff; color: #5b21b6; border-radius: 999px; padding: 4px 10px; font-size: 11.5px; cursor: pointer; font-family: inherit; white-space: nowrap; }
.ai-chip:hover { background: #ede9fe; }
.ai-inputrow { display: flex; gap: 6px; align-items: flex-end; }
.ai-inputrow textarea { flex: 1; resize: none; border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 10px; font-family: inherit; font-size: 13px; user-select: text; -webkit-user-select: text; outline: none; }
.ai-inputrow textarea:focus { border-color: #7c3aed; box-shadow: 0 0 0 2px rgba(124,58,237,.15); }
.ai-inputrow button { width: 38px; height: 38px; border: 0; border-radius: 8px; background: linear-gradient(135deg, #7c3aed, #2563eb); color: #fff; font-size: 16px; cursor: pointer; }
.ai-inputrow button:disabled { opacity: .5; cursor: wait; }
.ai-hint { font-size: 10.5px; color: #94a3b8; margin-top: 4px; }
.ai-settings { padding: 12px 14px; overflow-y: auto; font-size: 12.5px; background: #fff; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.ai-settings h4 { margin-top: 4px; font-size: 13px; color: #1e3a8a; }
.ai-settings label { display: flex; flex-direction: column; gap: 3px; font-weight: 600; color: #334155; }
.ai-settings input[type=text], .ai-settings input:not([type]), .ai-settings input[type=password], .ai-settings input[type=number], .ai-settings select { border: 1px solid #cbd5e1; border-radius: 6px; padding: 6px 8px; font-family: inherit; font-size: 12.5px; user-select: text; outline: none; }
.ai-settings .ai-chk { flex-direction: row; align-items: flex-start; gap: 6px; font-weight: 500; }
.ai-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ai-note { font-size: 11.5px; color: #475569; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; padding: 7px 9px; line-height: 1.5; user-select: text; }
.ai-btnrow { display: flex; gap: 6px; flex-wrap: wrap; }

/* Hızlı işlemler */
.ai-quick { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #fafafa; }
.aq-head { padding: 10px 12px 6px; background: #fff; border-bottom: 1px solid #e5e7eb; }
.aq-head input { width: 100%; border: 1px solid #cbd5e1; border-radius: 8px; padding: 7px 10px; font: inherit; outline: none; user-select: text; }
.aq-head input:focus { border-color: #7c3aed; }
.aq-cats { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.aq-cats button { border: 1px solid #ddd6fe; background: #f5f3ff; color: #5b21b6; border-radius: 999px; padding: 3px 10px; font-size: 11.5px; cursor: pointer; font-family: inherit; }
.aq-cats button.on { background: #7c3aed; color: #fff; border-color: #7c3aed; }
.aq-grid { flex: 1; overflow-y: auto; padding: 10px 12px; display: grid; grid-template-columns: 1fr; gap: 6px; align-content: start; }
.aq-card { display: flex; gap: 10px; align-items: center; background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 8px 10px; cursor: pointer; position: relative; }
.aq-card:hover { border-color: #7c3aed; box-shadow: 0 2px 8px rgba(124,58,237,.15); }
.aq-ic { font-size: 20px; width: 28px; text-align: center; flex: none; }
.aq-card b { display: block; font-size: 12.5px; color: #1e293b; } .aq-card small { display: block; font-size: 11px; color: #64748b; margin-top: 1px; }
.aq-ai { margin-left: auto; border: 0; background: #ede9fe; border-radius: 6px; width: 26px; height: 26px; cursor: pointer; flex: none; }
.aq-empty { text-align: center; color: #94a3b8; padding: 24px; }
.aq-foot { padding: 7px 12px; font-size: 11px; color: #64748b; background: #fff; border-top: 1px solid #e5e7eb; }
.ai-chip-quick { background: #7c3aed; color: #fff; border-color: #7c3aed; font-weight: 600; }
.ai-chip-quick:hover { background: #6d28d9; }

.ai-head-btns button.on { background: #fde047; color: #713f12; }
.ai-meta { font-size: 10.5px; color: #94a3b8; margin: -2px 4px 0; }

.ai-head-btns select#aiQuick { background: rgba(255,255,255,.15); border: 0; color: #fff; height: 28px; border-radius: 6px; font-size: 12px; max-width: 96px; cursor: pointer; }
.ai-head-btns select#aiQuick option { color: #111; }

.ai-webrow { display: flex; align-items: center; gap: 6px; padding: 2px 2px 6px; font-size: 12.5px; color: #334155; cursor: pointer; user-select: none; }
.ai-webrow input { accent-color: #107c41; }
.ai-webrow small { color: #94a3b8; }
.ai-bubble a { color: #2563eb; word-break: break-all; }

/* ---- Geniş / takip edilebilir panel ---- */
.ai-dock { max-width: 960px; }
.ai-head { padding: 6px 10px; gap: 8px; }
.ai-title { min-width: 0; flex: 1; gap: 8px; }
.ai-title > div { min-width: 0; }
.ai-title small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-head-btns { flex: none; align-items: center; }
.ai-head-btns button { width: 26px; height: 26px; font-size: 13px; }
.ai-head-btns select#aiQuick { height: 26px; max-width: 84px; }
.ai-msgs { padding: 12px 14px; gap: 12px; }
.ai-msg { max-width: 97%; }
.ai-who { font-size: 10.5px; font-weight: 700; letter-spacing: .02em; color: #64748b; margin: 0 4px -2px; }
.ai-msg.user .ai-who { color: #1d4ed8; }
.ai-msg.user .ai-bubble { font-size: 13.5px; font-weight: 500; box-shadow: 0 1px 4px rgba(37,99,235,.35); }
.ai-msg.assistant .ai-bubble { font-size: 13.5px; line-height: 1.55; }
.ai-foot { padding: 6px 10px 8px; }
.ai-hint { display: none; }
.ai-webrow { padding: 0 2px 4px; font-size: 12px; }

/* Sağ panel: ekranın sağında, en üstten en alta kadar sabit; uygulama sol tarafta daralır */
.ai-dock { position: fixed; top: 0; right: 0; bottom: 0; height: 100vh; z-index: 200; box-shadow: -6px 0 18px rgba(0,0,0,.12); }
body.ai-open { padding-right: var(--ai-w, 25vw); }

/* Aç/kapa sekmesi: kapalıyken ekranın sağ kenarında, açıkken panelin sol kenarında */
#aiEdgeTab { position: fixed; right: 0; top: 50%; transform: translateY(-50%); z-index: 210; border: 0; border-radius: 10px 0 0 10px; padding: 14px 7px; background: linear-gradient(180deg, #7c3aed, #2563eb); color: #fff; font-weight: 700; font-size: 12.5px; font-family: inherit; cursor: pointer; writing-mode: vertical-rl; box-shadow: -2px 2px 10px rgba(37,99,235,.4); }
#aiEdgeTab:hover { filter: brightness(1.12); }
#aiEdgeTab.open { right: var(--ai-w, 25vw); writing-mode: horizontal-tb; padding: 18px 5px; font-size: 13px; background: #1e3a8a; border-radius: 8px 0 0 8px; box-shadow: -3px 0 8px rgba(0,0,0,.15); }
@media (max-width: 760px) { body.ai-open { padding-right: 0; } #aiEdgeTab.open { display: none; } }
.ai-title b { white-space: nowrap; font-size: 13px; }
.ai-title .ai-spark { font-size: 18px; }
.ai-head-btns { gap: 3px; }
.ai-head-btns button { width: 24px; }
.ai-head-btns select#aiQuick { max-width: 72px; padding: 0 2px; }

/* ---- Alt sayfa sekmeleri: kalan genişliğin tamamını kullanır (sağ panele kadar); sığmazsa adlar kısalır ---- */
body:not(.is-mobile) .sheet-tabs-bar { gap: 8px; }
body:not(.is-mobile) .sheets-nav-left { flex: 1 1 0; min-width: 0; max-width: none; overflow: hidden; }
body:not(.is-mobile) #sheetTabsContainer { min-width: 0; flex: 0 1 auto; overflow: hidden; }
body:not(.is-mobile) #sheetTabsContainer .sheet-tab-item { flex: 0 1 auto; min-width: 0; }
body:not(.is-mobile) #sheetTabsContainer .sheet-tab-item .sheet-title { min-width: 28px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body:not(.is-mobile) .add-sheet-btn { flex: none; }
body:not(.is-mobile) .sheets-status-right { flex: none; }
/* Panel açıkken durum çubuğu sadeleşir: sekmelere öncelik verilir */
body.ai-open:not(.is-mobile) .sheets-status-right .zoom-widget,
body.ai-open:not(.is-mobile) .sheets-status-right .status-calc-item:nth-of-type(n+4) { display: none; }

/* ---- Üst başlık dar alanda taşmaz: arama kutusu daralır, sağdaki düğmeler görünür kalır ---- */
body:not(.is-mobile) .office-header { overflow: hidden; gap: 8px; }
body:not(.is-mobile) .header-left, body:not(.is-mobile) .header-right { flex: none; }
body:not(.is-mobile) .header-center { flex: 1 1 60px; min-width: 40px; margin: 0 8px; }
body.ai-open:not(.is-mobile) .header-right .hdr-btn { padding: 5px 8px; white-space: nowrap; }
@media (max-width: 1500px) { body.ai-open:not(.is-mobile) .header-center { display: none; } }

/* Panel başlığı: üstte ad/model, altta sağlayıcı ve düğmeler (dar panelde sıkışmaz) */
.ai-head { flex-wrap: wrap; row-gap: 6px; }
.ai-title { flex: 1 1 100%; }
.ai-head-btns { flex: 1 1 100%; }
.ai-head-btns select#aiQuick { flex: 1; max-width: none; margin-right: 4px; }
.ai-head-btns button { width: 28px; height: 28px; }
