/* ══════════════════════════════════════════
   Themis Control Panel — kabuk ve panel bileşenleri
   Ortak katman: css/themis/{tokens,components,utilities}.css
   ══════════════════════════════════════════ */

html { font-size: 14px; }
@media (min-width: 768px) { html { font-size: 15px; } }
body.cp-body { margin: 0; min-height: 100vh; }

/* ── Kabuk ── */
.cp-shell { display: flex; min-height: 100vh; }
.cp-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.cp-content { flex: 1 0 auto; padding: 1.5rem clamp(1rem, 3vw, 2rem); }
.cp-footer { padding: 1rem; text-align: center; color: var(--text-3); font-size: .82rem; }

/* ── Yan menü ── */
.cp-sidebar {
  flex: 0 0 var(--sidebar-w); width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-text);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; overscroll-behavior: contain; padding: 1rem .75rem;
  display: flex; flex-direction: column; gap: 1rem; z-index: 50;
}
.cp-brand { display: flex; align-items: center; gap: .65rem; padding: .35rem .5rem; color: #fff; font-weight: 600; font-size: 1.15rem; text-decoration: none; }
.cp-brand:hover { text-decoration: none; }
.cp-brand small { font-weight: 400; color: var(--sidebar-text); font-size: .85rem; margin-left: .15rem; }
.cp-brand-mark { width: 2.1rem; height: 2.1rem; display: inline-grid; place-items: center; border-radius: 10px; background: var(--brand-mark-bg); color: var(--brand-mark-color); font-weight: 700; }
.cp-nav { display: flex; flex-direction: column; gap: 2px; }
.cp-link {
  display: flex; align-items: center; gap: .75rem; padding: .65rem .8rem; border-radius: var(--radius);
  color: var(--sidebar-text); font-size: .92rem; font-weight: 500; cursor: pointer; list-style: none; text-decoration: none;
  min-height: 42px;
}
.cp-link::-webkit-details-marker { display: none; }
.cp-link > i:first-child { width: 1.25rem; text-align: center; opacity: .85; }
.cp-link:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.cp-link.active { background: var(--sidebar-active); color: var(--sidebar-active-text); }
.cp-caret { margin-left: auto; font-size: .7rem; opacity: .7; transition: transform .15s; }
.cp-group[open] > summary .cp-caret { transform: rotate(180deg); }
.cp-sub { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 4px; padding-left: 1.4rem; border-left: 1px solid rgba(255, 255, 255, .12); margin-left: 1.3rem; }
.cp-sub .cp-link { padding: .5rem .75rem; font-size: .87rem; min-height: 38px; }

/* ── Üst çubuk ── */
.cp-topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: .75rem; min-height: var(--topbar-h);
  padding: .5rem clamp(1rem, 3vw, 2rem); background: var(--surface); border-bottom: 1px solid var(--border);
}
.cp-title { margin: 0; font-size: 1.2rem; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-burger { display: none; width: 44px; height: 44px; border: 0; border-radius: var(--radius); background: none; color: var(--text); font-size: 1.15rem; cursor: pointer; }
.cp-burger:hover { background: var(--surface-2); }
.cp-user { position: relative; }
.cp-user > summary { list-style: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; font-size: 1.6rem; color: var(--text-2); cursor: pointer; }
.cp-user > summary::-webkit-details-marker { display: none; }
.cp-user > summary:hover { background: var(--surface-2); }
.cp-user-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 14rem; max-width: calc(100vw - 2rem); padding: .4rem; background: var(--surface-pop, var(--surface)); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 60; }
.cp-user-menu a, .cp-user-name { display: block; padding: .6rem .75rem; border-radius: var(--radius-sm); }
.cp-user-name { color: var(--text-2); font-size: .85rem; border-bottom: 1px solid var(--border); margin-bottom: .25rem; word-break: break-all; }
.cp-user-menu a:hover { background: var(--surface-2); text-decoration: none; }
.cp-scrim { display: none; }

@media (max-width: 991px) {
  .cp-sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(290px, 86vw); transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-xl); }
  body.cp-nav-open .cp-sidebar { transform: none; }
  body.cp-nav-open .cp-scrim { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(15, 23, 42, .5); }
  body.cp-nav-open { overflow: hidden; }
  .cp-burger { display: inline-grid; place-items: center; }
}

/* ── Panel sayfa içi bileşenleri ── */
.subheader { font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.row-cards { --bs-gx: 1rem; --bs-gy: 1rem; }
.row-cards > * { margin-top: var(--bs-gy); }
.row-deck > * { display: flex; } .row-deck > * > .card { flex: 1 1 auto; width: 100%; }
.h1 { font-size: 1.75rem; font-weight: 600; line-height: 1.25; } .h2 { font-size: 1.4rem; font-weight: 600; } .h3 { font-size: 1.15rem; font-weight: 600; }
.container-xl { width: 100%; max-width: 1320px; margin: 0 auto; }
.container-tight { width: 100%; max-width: 26rem; margin: 0 auto; padding: 0 1rem; }
.page-center { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.text-green { color: var(--success) !important; }
.fw-bold { font-weight: 700; }

.card-table { margin: 0; }
.card-table th:first-child, .card-table td:first-child { padding-left: 1.25rem; }
.card-table th:last-child, .card-table td:last-child { padding-right: 1.25rem; }
.table-vcenter td, .table-vcenter th { vertical-align: middle; }
.card > .table-responsive:last-child, .card > .table:last-child { border-bottom-left-radius: inherit; border-bottom-right-radius: inherit; }

.datagrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr)); gap: 1.1rem 1.5rem; }
.datagrid-title { font-size: .72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-2); margin-bottom: .2rem; }
.datagrid-content { min-height: 1.5rem; word-break: break-word; }

.avatar { display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: var(--radius); background: var(--surface-3); color: var(--text-2); font-weight: 600; font-size: .9rem; flex: none; overflow: hidden; }
.avatar-sm { width: 2rem; height: 2rem; font-size: .8rem; } .avatar-lg { width: 4rem; height: 4rem; font-size: 1.3rem; }
.avatar.rounded { border-radius: var(--radius); }

.empty { text-align: center; padding: 2.5rem 1rem; }
.empty-icon { font-size: 2.2rem; margin-bottom: .75rem; }
.empty-title { font-size: 1.1rem; font-weight: 600; margin: 0 0 .25rem; }
.empty-subtitle { margin: 0 0 1rem; }
.empty-action { margin-top: 1rem; }

/* açık tonlu rozet ve avatar renkleri */
.bg-green-lt, .bg-success-lt { background: color-mix(in srgb, var(--success) 14%, var(--surface)) !important; color: var(--success) !important; }
.bg-yellow-lt, .bg-orange-lt, .bg-warning-lt { background: color-mix(in srgb, var(--warning) 18%, var(--surface)) !important; color: #9a5b00 !important; }
.bg-danger-lt, .bg-red-lt { background: color-mix(in srgb, var(--danger) 13%, var(--surface)) !important; color: var(--danger) !important; }
.bg-blue-lt, .bg-azure-lt, .bg-info-lt { background: color-mix(in srgb, var(--info) 14%, var(--surface)) !important; color: var(--info) !important; }
.bg-purple-lt { background: color-mix(in srgb, #7C3AED 14%, var(--surface)) !important; color: #6D28D9 !important; }
.bg-secondary-lt, .bg-secondary { background: var(--surface-3) !important; color: var(--text-2) !important; }
.badge.bg-success, .badge.bg-warning, .badge.bg-danger, .badge.bg-primary, .badge.bg-info { color: #fff; }
.badge.bg-warning { color: #3b2a00; }

/* liste grubu */
.list-group { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.list-group-item { display: block; padding: .8rem 1rem; border-bottom: 1px solid var(--border); color: var(--text); }
.list-group-flush > .list-group-item:last-child { border-bottom: 0; }
.list-group-item-action { text-decoration: none; cursor: pointer; } .list-group-item-action:hover { background: var(--surface-2); text-decoration: none; }

/* sekmeler */
.nav-tabs { display: flex; gap: .25rem; margin: 0; padding: 0; list-style: none; border-bottom: 1px solid var(--border); }
.nav-tabs .nav-link { display: block; padding: .6rem 1rem; border-bottom: 2px solid transparent; color: var(--text-2); font-weight: 500; }
.nav-tabs .nav-link:hover { color: var(--text); text-decoration: none; } .nav-tabs .nav-link.active { color: var(--primary); border-bottom-color: var(--primary); }
.card-header-tabs { margin: -.5rem 0 -1px; border-bottom: 0; }
.card-header-tabs .nav-link { padding: .75rem 1rem; }

/* düğme / form ek parçaları */
.btn-icon { width: var(--ctrl-h); padding: 0; justify-content: center; }
.btn-ghost-secondary { background: transparent; border-color: transparent; color: var(--text-2); } .btn-ghost-secondary:hover { background: var(--surface-2); color: var(--text); }
.form-check-input { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--primary); vertical-align: middle; cursor: pointer; }
.form-footer { margin-top: 1.25rem; }
.card-md .card-body { padding: 2rem; }
.alert-dismissible { position: relative; padding-right: 3rem; }
.alert-dismissible .btn-close { position: absolute; top: .55rem; right: .6rem; }
.dropdown-menu.show { display: block; }
.dropdown-menu-end { left: auto; right: 0; } .dropdown-header { display: block; padding: .4rem .75rem; font-size: .75rem; color: var(--text-2); }
.progress-sm { height: .35rem; }
.progress-bar-indeterminate { width: 40% !important; animation: cp-ind 1.4s linear infinite; } @keyframes cp-ind { from { margin-left: -40%; } to { margin-left: 100%; } }
.spinner-border { display: inline-block; width: 1em; height: 1em; border: .15em solid currentColor; border-right-color: transparent; border-radius: 50%; animation: cp-spin .7s linear infinite; vertical-align: -.125em; }
.spinner-border-sm { width: .85em; height: .85em; } @keyframes cp-spin { to { transform: rotate(360deg); } }
.modal-status { height: 4px; border-radius: var(--radius) var(--radius) 0 0; }
.chart { min-height: 14rem; }

/* ── Dokunmatik / touchpad / küçük ekran ── */
/* tablolar: yatay kaydırma iki parmak (touchpad) ve dokunmatik ile çalışır; geri-gezinme hareketi kaydırmayı çalmasın */
.table-responsive { overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.table-responsive > .table { min-width: 640px; }
.table-responsive .btn, .table td .btn { white-space: nowrap; }
.table td:last-child .btn-group, .table td:last-child .d-flex { flex-wrap: nowrap; }
/* tablo taşarsa işlem sütunu (son sütun) sağda sabit kalır; taşmazsa görünüşü değişmez */
.table-responsive > .table td:last-child:has(.btn), .table-responsive > .table th:last-child:has(+ :not(th)), .table-responsive > .table td.cp-actions { position: sticky; right: 0; background: var(--surface); box-shadow: -8px 0 8px -8px rgba(19, 39, 78, .18); }
@media (max-width: 767px) {
  /* telefonda tablolar kart olur (başlıklar data-label ile hücreye taşınır) */
  .table-responsive:has(> table.table-stack) { overflow: visible; }
  table.table-stack, table.table-stack tbody, table.table-stack tr, table.table-stack td { display: block; width: 100% !important; min-width: 0 !important; }
  table.table-stack thead { display: none; }
  table.table-stack tbody tr { margin: 0 0 .75rem; padding: .35rem .9rem; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-sm); }
  table.table-stack td { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .5rem 0 !important; border: 0 !important; border-bottom: 1px dashed var(--border) !important; text-align: right !important; white-space: normal !important; position: static !important; box-shadow: none !important; background: none !important; }
  table.table-stack td:last-child { border-bottom: 0 !important; }
  table.table-stack td::before { content: attr(data-label); flex: 0 0 38%; max-width: 38%; text-align: left; font-size: .78rem; font-weight: 600; color: var(--text-2); }
  table.table-stack td[data-label=""]::before { display: none; }
  table.table-stack td:first-child { display: block; text-align: left !important; padding-top: .6rem !important; font-size: 1.02em; }
  table.table-stack td:first-child::before { display: none; }
  table.table-stack td[data-label=""]:not(:first-child) { justify-content: flex-end; }
  table.table-stack td[data-label=""] .btn { min-width: 7rem; }
  table.table-stack td[colspan] { display: block; text-align: center !important; } table.table-stack td[colspan]::before { display: none; }
  .card:has(> .table-responsive > table.table-stack) { background: none; border: 0; box-shadow: none; }
}
@media (max-width: 767px) {
  .cp-content { padding: 1rem .85rem; }
  .row { --bs-gx: .75rem; }
  .card-body { padding: 1rem; }
  .btn:not(.btn-sm):not(.btn-close) { min-height: 44px; }
  .form-control, .form-select { min-height: 44px; font-size: 16px; } /* iOS yakınlaştırmasını önler */
  .modal-dialog { margin: .5rem; max-width: none; }
  .modal-footer { flex-wrap: wrap; } .modal-footer .btn { flex: 1 1 auto; }
  .card-header { flex-wrap: wrap; gap: .5rem; }
  .datagrid { grid-template-columns: 1fr 1fr; gap: .9rem 1rem; }
  .empty { padding: 1.5rem .5rem; }
}
@media (max-width: 479px) { .datagrid { grid-template-columns: 1fr; } }
/* fare olmayan cihazlarda hover'a bağlı bilgiler odakla da açılsın; dokunma hedefleri büyür */
@media (hover: none) and (pointer: coarse) {
  .cp-link, .dropdown-item, .page-link { min-height: 44px; }
  .btn-sm { min-height: 38px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation-duration: .01ms !important; } }
@media print { .cp-sidebar, .cp-topbar, .cp-footer { display: none !important; } .cp-content { padding: 0; } }

/* Tabler'dan kalan, tema katmanında karşılığı olmayan yardımcı sınıflar (eksik outline butonlar görünmez kalıyordu) */
.btn-outline-success { --b: var(--success); --b-contrast: #fff; }
.btn-outline-warning { --b: var(--warning); --b-contrast: #1f1500; }
.btn-outline-info { --b: var(--info); --b-contrast: #fff; }
.text-azure { color: var(--info) !important; }
.text-orange, .text-yellow { color: #b45309 !important; }
.text-purple { color: #6D28D9 !important; }
.text-reset { color: inherit !important; }
.bg-muted, .bg-orange { background: var(--surface-2) !important; }
.alert-title { font-weight: 600; margin-bottom: .25rem; }

/* ───────── Bildirim (toast) ve onay penceresi (notify.js) ───────── */
.th-toasts { position: fixed; top: 1rem; right: 1rem; z-index: 2000; display: flex; flex-direction: column; gap: .6rem; width: min(400px, calc(100vw - 2rem)); pointer-events: none; }
.th-toast { --tc: var(--info); pointer-events: auto; position: relative; display: flex; align-items: flex-start; gap: .75rem; padding: .85rem .9rem .95rem 1rem; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--tc); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(15, 23, 42, .18); overflow: hidden; opacity: 0; transform: translateX(24px); transition: opacity .2s ease, transform .2s ease; }
.th-toast.is-in { opacity: 1; transform: none; }
.th-toast.is-out { opacity: 0; transform: translateX(24px); }
.th-toast-success { --tc: var(--success); } .th-toast-error { --tc: var(--danger); } .th-toast-warning { --tc: var(--warning); } .th-toast-info { --tc: var(--info); }
.th-toast-icon { color: var(--tc); font-size: 1.15rem; margin-top: .1rem; }
.th-toast-body { flex: 1; min-width: 0; font-size: .92rem; line-height: 1.4; word-break: break-word; }
.th-toast-title { font-weight: 600; margin-bottom: .1rem; }
.th-toast-msg > div + div { margin-top: .15rem; }
.th-toast-x { border: 0; background: transparent; color: var(--text-2, #64748b); width: 1.9rem; height: 1.9rem; margin: -.3rem -.35rem 0 0; border-radius: 6px; cursor: pointer; flex: none; }
.th-toast-x:hover { background: var(--surface-2); color: var(--text); }
.th-toast-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--tc); opacity: .55; transform-origin: left; }
@media (max-width: 575.98px) { .th-toasts { top: auto; bottom: calc(.75rem + env(safe-area-inset-bottom)); right: .75rem; left: .75rem; width: auto; } .th-toast { transform: translateY(16px); } .th-toast.is-out { transform: translateY(16px); } }

dialog.th-dialog { border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); padding: 0; width: min(440px, calc(100vw - 2rem)); background: var(--surface); color: var(--text); box-shadow: 0 24px 60px rgba(15, 23, 42, .3); }
dialog.th-dialog::backdrop { background: rgba(15, 23, 42, .5); }
dialog.th-dialog[open] { animation: thDlgIn .16s ease-out; }
@keyframes thDlgIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.th-dialog-card { display: grid; grid-template-columns: auto 1fr; gap: .9rem 1rem; padding: 1.4rem 1.4rem 1.1rem; margin: 0; }
.th-dialog-icon { width: 2.6rem; height: 2.6rem; border-radius: 50%; display: grid; place-items: center; font-size: 1.1rem; background: var(--primary-soft, var(--surface-2)); color: var(--primary-text, var(--primary)); }
.th-dialog-danger .th-dialog-icon { background: color-mix(in srgb, var(--danger) 13%, var(--surface)); color: var(--danger); }
.th-dialog-warning .th-dialog-icon { background: color-mix(in srgb, var(--warning) 18%, var(--surface)); color: #9a6700; }
.th-dialog-title { margin: .1rem 0 .3rem; font-size: 1.05rem; font-weight: 600; }
.th-dialog-msg { color: var(--text-2, #475569); font-size: .93rem; line-height: 1.5; }
.th-dialog-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: .6rem; margin-top: .4rem; }
@media (max-width: 480px) { .th-dialog-actions { flex-direction: column-reverse; } .th-dialog-actions .btn { width: 100%; } }
@media (prefers-reduced-motion: reduce) { .th-toast, dialog.th-dialog[open] { transition: none; animation: none; } }
