/* Kuzey Agent — panel; temel dil bmw.css'te (kuzey-bmw ile ortak) */
body { font-size: .9rem; background: var(--bmw-white); color: var(--bmw-black); }

.bmw-meta { font-size: .85rem; color: var(--bmw-grey-600); }
.agent-state { text-decoration: none; color: var(--bmw-grey-600); }
a.agent-state:hover { color: var(--bmw-black); }
.agent-link { font-size: .75rem; font-weight: 500; letter-spacing: 0; text-transform: none; text-decoration: none; }
.agent-uptime { font-weight: 500; letter-spacing: 0; text-transform: none; }

.bmw-dot-warn { background: #f5a623; box-shadow: 0 0 0 3px rgba(245,166,35,.18); }
.bmw-dot-err  { background: var(--bmw-danger); box-shadow: 0 0 0 3px rgba(210,0,0,.15); }
.bmw-dot-busy { background: var(--bmw-blue); animation: agent-pulse 1s infinite alternate; }
@keyframes agent-pulse { from { opacity: 1 } to { opacity: .3 } }

/* ============ Parca Ara ============ */
.agent-search { display: flex; align-items: flex-end; gap: 1rem; margin-bottom: 1.5rem; }
.agent-search .bmw-search input { font-size: 1.25rem; font-weight: 300; padding-top: .5rem; }
.agent-search .btn { min-width: 128px; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; }
input[type="search"]::-webkit-search-cancel-button { display: none; }

/* Ilerleme: ince mavi cizgi */
.agent-run { margin-bottom: 1.25rem; }
.agent-progress { height: 2px; background: var(--bmw-grey-200); overflow: hidden; }
.agent-progress .bar { height: 100%; width: 0; background: var(--bmw-blue); transition: width .3s var(--bmw-ease); }
.agent-progress .bar.done { background: var(--bmw-black); }
.agent-run-head { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem 0; font-size: .85rem; color: var(--bmw-grey-600); }
.agent-run-head strong { color: var(--bmw-black); font-weight: 500; }
.agent-run-head .btn-link { font-size: .8rem; text-decoration: none; }

/* Bayi cipleri: 30 bayi sigsin diye kompakt, sarmali */
.agent-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.agent-chip {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .3rem .6rem; font-size: .78rem; line-height: 1.3;
  border: 1px solid var(--bmw-grey-200); background: var(--bmw-white); color: var(--bmw-grey-900);
  transition: border-color .15s var(--bmw-ease), background .15s var(--bmw-ease);
}
.agent-chip .n { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-chip b { font-weight: 700; color: var(--bmw-blue); font-variant-numeric: tabular-nums; }
.agent-chip .spinner-border { width: .7rem; height: .7rem; border-width: 1.5px; color: var(--bmw-grey-400); }
.agent-chip.is-ok { cursor: pointer; border-color: var(--bmw-grey-300); }
.agent-chip.is-ok:hover { border-color: var(--bmw-blue); }
.agent-chip.is-empty { color: var(--bmw-grey-400); }
.agent-chip.is-empty b { color: var(--bmw-grey-400); }
.agent-chip.is-error { color: var(--bmw-danger); border-color: rgba(210,0,0,.3); }
.agent-chip.is-pending { color: var(--bmw-grey-400); border-style: dashed; }
.agent-chip.active { background: var(--bmw-blue); border-color: var(--bmw-blue); color: #fff; }
.agent-chip.active b { color: #fff; }
.agent-chip:disabled { opacity: 1; }

/* Sonuc filtreleri */
.agent-filters { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; padding: .25rem 0 1rem; }
.agent-filters .form-check { margin: 0; font-size: .85rem; }
.agent-filter-text { min-width: 220px; flex: 1; max-width: 340px; }
.agent-filter-text input { font-size: .85rem; padding: .45rem 1.75rem .45rem 0; }
.agent-filter-text i { font-size: .9rem; }
.agent-shown { font-size: .8rem; color: var(--bmw-grey-600); margin-left: auto; }

/* Sonuc tablosu */
.agent-results td { white-space: normal !important; }
.agent-results .code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .85rem; }
.agent-results .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap !important; }
.agent-results .price { font-weight: 700; font-size: 1rem; }
.agent-results tr.best td, .agent-results tr.best th { background: var(--bmw-blue-light); }
.agent-results tr.best .price { color: var(--bmw-blue); }
.agent-results tr.noprice td { color: var(--bmw-grey-400); }
.agent-results .desc { max-width: 340px; }
.agent-results .list { display: block; font-size: .75rem; color: var(--bmw-grey-400); text-decoration: line-through; }
.agent-results .tag { display: block; font-size: .72rem; color: var(--bmw-grey-600); }
[data-bs-theme="dark"] .agent-results tr.best td,
[data-bs-theme="dark"] .agent-results tr.best th { background: rgba(77,143,230,.12); }

/* Sepete ekle (sonuc satiri) */
.agent-addcart { display: inline-flex; align-items: center; gap: .3rem; }
.agent-addcart input.form-control { width: 3.6rem; padding: .3rem .35rem; font-size: .85rem; text-align: center; border: 1px solid var(--bmw-grey-300); }
.agent-addcart .btn { padding: .32rem .6rem; line-height: 1.2; }
.agent-addcart .spinner-border { width: .85rem; height: .85rem; border-width: 1.5px; }
.agent-carted { font-size: .8rem; font-weight: 500; color: var(--bmw-success); text-decoration: none; white-space: nowrap; }
.agent-carted:hover { text-decoration: underline; color: var(--bmw-success); }

/* ============ Sepet sayfasi ============ */
.agent-recap-4 { grid-template-columns: repeat(4, 1fr); }
.agent-cart-note { font-size: .82rem; color: var(--bmw-grey-600); margin: 0 0 1.5rem; }
.agent-cart-note i { margin-right: .25rem; }
/* Ozet kartlari */
.agent-cart-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.agent-cart-cards > .bmw-empty, .agent-cart-unsupported { grid-column: 1 / -1; }
.agent-cart-card { display: flex; flex-direction: column; align-items: stretch; gap: .2rem; text-align: left; padding: 1rem 1.1rem 1.1rem;
  background: var(--bmw-white); color: var(--bmw-black); border: 1px solid var(--bmw-grey-200); border-top: 3px solid var(--bmw-black);
  transition: border-color .15s, box-shadow .15s; min-height: 170px; }
.agent-cart-card:hover:not(:disabled) { border-color: var(--bmw-blue); box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.agent-cart-card:disabled { opacity: 1; cursor: progress; }
.agent-cart-card.is-error { border-top-color: var(--bmw-danger); }
.agent-cart-card .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .35rem; }
.agent-cart-card .name { font-size: 1rem; font-weight: 500; }
.agent-cart-card .head i { color: var(--bmw-grey-400); font-size: .85rem; }
.agent-cart-card:hover .head i { color: var(--bmw-blue); }
.agent-cart-card .total { font-size: 1.5rem; font-weight: 300; font-variant-numeric: tabular-nums; }
.agent-cart-card .meta { font-size: .8rem; color: var(--bmw-grey-600); }
.agent-cart-preview { list-style: none; padding: .5rem 0 0; margin: .4rem 0 0; border-top: 1px solid var(--bmw-grey-100); font-size: .78rem; }
.agent-cart-preview li { display: flex; justify-content: space-between; gap: .5rem; padding: .1rem 0; }
.agent-cart-preview .code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-cart-preview .q { color: var(--bmw-grey-600); white-space: nowrap; }
.agent-cart-preview .more { color: var(--bmw-blue); }
.agent-cart-empty-text { margin-top: .6rem; font-size: .8rem; color: var(--bmw-grey-400); }
.agent-cart-card-wait { color: var(--bmw-grey-600); font-size: .85rem; margin-top: .5rem; }
.agent-cart-card-wait .spinner-border { width: .85rem; height: .85rem; border-width: 1.5px; margin-right: .3rem; }
.agent-cart-card-error { color: var(--bmw-danger); font-size: .82rem; margin-top: .5rem; line-height: 1.4; }

/* Tam ekran detay */
#cart-detail .modal-header.agent-cart-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  border-bottom: 2px solid var(--bmw-black); padding: 1rem 1.5rem; }
#cart-detail .modal-title { font-size: 1.3rem; font-weight: 500; margin: 0; }
#cart-detail .meta { font-size: .8rem; color: var(--bmw-grey-600); }
#cart-detail .modal-body { padding: 1rem 1.5rem 2rem; }
.agent-cart-tools { display: flex; align-items: center; gap: .35rem; }
.agent-cart-tools .total { font-size: 1.2rem; font-weight: 700; margin-right: .5rem; font-variant-numeric: tabular-nums; }
.agent-cart-tools .btn { padding: .3rem .55rem; border: 1px solid var(--bmw-grey-300); }
.agent-cart-tools .btn:hover { border-color: var(--bmw-blue); color: var(--bmw-blue); }
.agent-cart-table td { white-space: nowrap; }
.agent-cart-table td.desc { white-space: normal; }

/* Sekmeler (Arama / Aranan Parcalar) */
.agent-tabs { margin-bottom: 1.25rem; }
.agent-tabs .nav-link i { margin-right: .25rem; }

/* Kayitli sonuc bandi */
.agent-saved {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .65rem .9rem; margin-bottom: 1rem;
  border-left: 3px solid var(--bmw-blue); background: var(--bmw-grey-100);
  font-size: .85rem; color: var(--bmw-grey-900);
}
.agent-saved i { color: var(--bmw-blue); }
.agent-saved .btn { margin-left: auto; padding: .4rem .9rem; font-size: .8rem; }

/* Aranan parcalar tablosu */
.agent-mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .9rem; }
.bmw-list td a.agent-mono { font-weight: 500; }
.agent-parts .sub, #part-history .sub { display: block; font-size: .76rem; color: var(--bmw-grey-600); }
.agent-parts .price { font-weight: 700; }
.agent-parts td { white-space: nowrap; }
.bmw-list td a.agent-count { color: var(--bmw-black); }
.agent-delta { display: inline-flex; align-items: center; margin-left: .35rem; font-size: .72rem; font-weight: 700; }
.agent-delta.up { color: var(--bmw-danger); }
.agent-delta.down { color: var(--bmw-success); }
#part-history .bmw-table thead th:first-child, #part-history .bmw-table tbody td:first-child { padding-left: 1.5rem; }
#part-history .bmw-table td:last-child { padding-right: 1.5rem; }

/* Kenar */
.agent-side { padding-top: 2rem; }
.agent-conn > div:last-child dd { color: var(--bmw-black); }
.agent-problems { list-style: none; padding: 0; margin: .5rem 0 0; font-size: .8rem; }
.agent-problems li { display: grid; grid-template-columns: auto 1fr; column-gap: .5rem; align-items: center; padding: .4rem 0; border-bottom: 1px solid var(--bmw-grey-100); }
.agent-problems li a { color: var(--bmw-black); text-decoration: none; font-weight: 500; }
.agent-problems li a:hover { color: var(--bmw-blue); }
.agent-problems li small { grid-column: 2; color: var(--bmw-grey-600); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-problems li.more { display: block; }
.agent-side .list-group-item { cursor: pointer; display: flex; justify-content: space-between; gap: .5rem; }
.agent-side .list-group-item .q { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .85rem; }
.agent-side .list-group-item .p { font-size: .78rem; color: var(--bmw-grey-600); white-space: nowrap; }
.agent-side .list-group-item:hover .q { color: var(--bmw-blue); }

/* ============ Bayiler ============ */
.agent-recap { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--bmw-grey-200); margin-bottom: 1.5rem; }
.agent-recap > div { padding: .85rem 1rem; border-right: 1px solid var(--bmw-grey-200); }
.agent-recap > div:last-child { border-right: 0; }
.agent-recap span { display: block; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--bmw-grey-600); margin-bottom: .2rem; }
.agent-recap strong { font-size: 1.35rem; font-weight: 300; }
.agent-recap strong.ok { color: var(--bmw-success); }
.agent-recap strong.bad { color: var(--bmw-danger); }
.agent-recap small { display: block; font-size: .75rem; color: var(--bmw-grey-600); }

.agent-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-bottom: 1px solid var(--bmw-grey-200); margin-bottom: .5rem; }
/* Dar ekranda yatay kaydirilir; sekmelerin -1px alt marjı dikey kaydirma cubugu cikarmasin. */
.agent-toolbar .bmw-tabs { border-bottom: 0; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.agent-toolbar .bmw-tabs::-webkit-scrollbar { display: none; }
.agent-toolbar .nav-link { white-space: nowrap; }
.agent-toolbar .agent-filter-text { margin-bottom: .35rem; }

.agent-dealers-table .sub { display: block; font-size: .78rem; color: var(--bmw-grey-600); text-decoration: none; }
.agent-dealers-table a.sub:hover { color: var(--bmw-blue); }
.agent-dealers-table .bmw-person { gap: .7rem; }
.agent-dealers-table tr.target td { background: var(--bmw-blue-light); }
.agent-state-cell { white-space: normal !important; max-width: 320px; }
.agent-state-cell .msg { font-size: .76rem; color: var(--bmw-danger); margin-top: .25rem; line-height: 1.35; }
.agent-st { display: inline-flex; padding: .22rem .55rem; font-size: .75rem; font-weight: 500; border: 1px solid var(--bmw-grey-300); white-space: nowrap; }
.agent-st-online { color: var(--bmw-success); border-color: rgba(46,133,64,.35); background: rgba(46,133,64,.07); }
.agent-st-error, .agent-st-paused { color: var(--bmw-danger); border-color: rgba(210,0,0,.35); background: rgba(210,0,0,.06); }
.agent-st-waiting, .agent-st-logging_in { color: var(--bmw-blue); border-color: rgba(28,105,212,.4); background: var(--bmw-blue-light); }
.agent-st-disabled { color: var(--bmw-grey-600); background: var(--bmw-grey-100); }
[data-bs-theme="dark"] .agent-st-waiting, [data-bs-theme="dark"] .agent-st-logging_in,
[data-bs-theme="dark"] .agent-dealers-table tr.target td { background: rgba(77,143,230,.12); }
.agent-actions { white-space: nowrap; }
.agent-actions .btn + .btn { margin-left: .25rem; }
.agent-actions .btn:disabled { opacity: .35; }
.bmw-list th[sort] i { font-size: .75rem; }

/* Olay gunlugu */
.agent-events { list-style: none; padding: 0; margin: 0; font-size: .8rem; max-height: 320px; overflow: auto; }
.agent-events li { padding: .4rem 0; border-bottom: 1px solid var(--bmw-grey-100); color: var(--bmw-grey-900); }
.agent-events time { color: var(--bmw-grey-400); margin-right: .5rem; font-variant-numeric: tabular-nums; }
.agent-events .d { font-weight: 700; margin-right: .35rem; }
.agent-events .error { color: var(--bmw-danger); }
.agent-events .warn { color: #b26a00; }
.agent-events-wide { columns: 2 420px; column-gap: 2rem; max-height: none; }
.agent-events-wide li { break-inside: avoid; }

/* Modal: bmw.css .input-group-text 130px */
#edit .input-group-text { width: 140px; }
#edit .form-control::placeholder { font-size: .8rem; }
#edit [data-reveal] { border: 1px solid var(--bmw-grey-300); border-left: 0; color: var(--bmw-grey-600); }

/* Koyu mod: bmw.css bunlari acik renge sabitliyor */
[data-bs-theme="dark"] .bmw-header { background: var(--bmw-white); }
[data-bs-theme="dark"] .bmw-header .navbar-nav .nav-link.active,
[data-bs-theme="dark"] .bmw-header .navbar-brand { color: var(--bmw-black); }
[data-bs-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

@media (max-width: 991.98px) {
  .agent-recap:not(.agent-recap-4) { grid-template-columns: repeat(3, 1fr); }
  .agent-recap:not(.agent-recap-4) > div:nth-child(3) { border-right: 0; }
  .agent-recap:not(.agent-recap-4) > div:nth-child(n+4) { border-top: 1px solid var(--bmw-grey-200); }
}
@media (max-width: 575.98px) {
  .agent-search { flex-direction: column; align-items: stretch; }
  .bmw-page-head h1 { font-size: 1.6rem; }
  .agent-recap { grid-template-columns: repeat(2, 1fr); }
  .agent-recap > div { border-right: 0; border-top: 1px solid var(--bmw-grey-200); }
  .agent-recap > div:nth-child(odd) { border-right: 1px solid var(--bmw-grey-200); }
  .agent-recap > div:nth-child(-n+2) { border-top: 0; }
  .agent-shown { margin-left: 0; }
  .agent-recap > div:last-child { grid-column: span 2; border-right: 0; }
  .agent-recap-4 > div:last-child { grid-column: auto; border-right: 0; }
}

/* Dar ekran: tablo satirlari kart olur (etiket solda, deger sagda) */
@media (max-width: 767.98px) {
  .agent-cardtable thead { display: none; }
  .agent-cardtable, .agent-cardtable tbody, .agent-cardtable tr, .agent-cardtable td, .agent-cardtable th { display: block; width: 100%; }
  .agent-cardtable tbody tr { border-bottom: 1px solid var(--bmw-black); padding: .5rem 0; position: relative; }
  .agent-cardtable tbody tr:has(.bmw-empty) { border-bottom: 0; }
  .bmw-table .agent-cardtable tbody td { position: relative; border-bottom: 0; padding: .3rem 0 .3rem 7.5rem; text-align: right; min-height: 1.9rem; }
  .agent-cardtable td[data-label]::before {
    content: attr(data-label);
    position: absolute; left: 0;
    font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    color: var(--bmw-grey-600); padding-top: .15rem;
  }
  .agent-cardtable td:has(.bmw-empty) { padding: 0 !important; text-align: center !important; }
  .agent-cardtable th.n { position: absolute; right: 0; top: .6rem; width: auto; padding: 0; font-size: .75rem; }
  .agent-cardtable td[data-label="Bayi"] { padding-right: 2rem; }
  .agent-cardtable td.agent-actions { padding-left: 0 !important; text-align: right; }
  .agent-cardtable td:not([data-label]):not(.agent-actions) { padding-left: 0 !important; text-align: left; }
  .agent-state-cell { max-width: none; }
  .agent-state-cell .msg { text-align: right; }
  .agent-parts td { white-space: normal; }
  .agent-cardtable .desc { max-width: none; }
}

/* ============ Diyalog (alert/confirm yerine) ============ */
.agent-dialog { z-index: 1070; }
.modal-backdrop.agent-dialog-backdrop { z-index: 1065; }
.agent-dialog .modal-dialog { max-width: 440px; }
.agent-dialog .modal-content { border-top: 3px solid var(--bmw-blue); }
.agent-dialog.is-error .modal-content, .agent-dialog.is-warning .modal-content { border-top-color: var(--bmw-danger); }
.agent-dialog.is-warning .modal-content { border-top-color: #f5a623; }
.agent-dialog.is-success .modal-content { border-top-color: var(--bmw-success); }
.agent-dialog .modal-body { display: flex; gap: 1rem; align-items: flex-start; padding: 1.5rem 1.5rem 1.25rem; }
.agent-dialog-icon { font-size: 1.6rem; line-height: 1; color: var(--bmw-blue); margin-top: .1rem; }
.agent-dialog.is-error .agent-dialog-icon { color: var(--bmw-danger); }
.agent-dialog.is-warning .agent-dialog-icon { color: #d48800; }
.agent-dialog.is-success .agent-dialog-icon { color: var(--bmw-success); }
.agent-dialog .modal-title { margin-bottom: .4rem; }
.agent-dialog-msg { color: var(--bmw-grey-900); line-height: 1.5; overflow-wrap: anywhere; }
.agent-dialog .modal-footer { padding: .85rem 1.5rem; }
.agent-dialog .modal-footer .btn { min-width: 96px; padding: .6rem 1.1rem; }

/* Ajan kapali bandi */
.agent-down { display: flex; gap: .75rem; align-items: flex-start; padding: .75rem .9rem; margin-bottom: 1rem;
  border-left: 3px solid var(--bmw-danger); background: rgba(210,0,0,.06); font-size: .82rem; }
.agent-down i { color: var(--bmw-danger); font-size: 1.15rem; line-height: 1.2; }
.agent-down strong { display: block; color: var(--bmw-danger); font-weight: 500; }
.agent-down span { color: var(--bmw-grey-900); }
.agent-down-wide { margin-bottom: 1.5rem; font-size: .88rem; }

/* Duzenle penceresi ici hata */
.agent-form-error { display: flex; gap: .6rem; align-items: flex-start; padding: .65rem .8rem; margin-bottom: 1rem;
  border-left: 3px solid var(--bmw-danger); background: rgba(210,0,0,.06); color: var(--bmw-danger); font-size: .85rem; }
.agent-form-error i { line-height: 1.3; }
