/* Kreditzen 2.0 — Bootstrap compatibility layer
   Styles legacy Bootstrap class names using kz design tokens so existing
   modals, forms, buttons, alerts, cards, badges, accordions and tables
   render correctly without loading Bootstrap CSS. Used while pages are
   being migrated to the kz-* component system. */

/* ─── Layout helpers ─── */
.container, .container-fluid { width: 100%; padding: 0; margin: 0 auto; }
.row { display: flex; flex-wrap: wrap; margin: 0; }
.row > [class*="col-"], .row > .col { padding: 0 8px; box-sizing: border-box; flex: 1 0 0%; min-width: 0; }
.row.g-3 > [class*="col-"] { padding: 6px; }
.row.g-4 > [class*="col-"] { padding: 8px; }
.col-12 { flex: 0 0 100%; max-width: 100%; }
.col-md-6, .col-lg-6 { flex: 0 0 100%; max-width: 100%; }
.col-md-4 { flex: 0 0 100%; max-width: 100%; }
.col-md-8, .col-lg-7, .col-lg-8, .col-xl-4 { flex: 0 0 100%; max-width: 100%; }
@media (min-width: 768px) {
  .col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
  .col-md-6 { flex: 0 0 50%; max-width: 50%; }
  .col-md-8 { flex: 0 0 66.666%; max-width: 66.666%; }
}
@media (min-width: 992px) {
  .col-lg-6 { flex: 0 0 50%; max-width: 50%; }
  .col-lg-7 { flex: 0 0 58.333%; max-width: 58.333%; }
  .col-lg-8 { flex: 0 0 66.666%; max-width: 66.666%; }
}
@media (min-width: 1200px) { .col-xl-4 { flex: 0 0 33.333%; max-width: 33.333%; } }

.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }
.justify-content-lg-end { justify-content: flex-start; }
@media (min-width: 992px) { .justify-content-lg-end { justify-content: flex-end; } }
.align-items-center { align-items: center; }
.align-items-end { align-items: flex-end; }
.text-center { text-align: center; }
.text-end { text-align: right; }
.text-start { text-align: left; }

.d-flex { display: flex; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-block { display: block; }
.d-grid { display: grid; grid-template-columns: 1fr; }
.d-none { display: none !important; }
.flex-grow-1 { flex-grow: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-wrap { flex-wrap: wrap; }
.flex-column { flex-direction: column; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.ms-2 { margin-left: 8px; } .ms-3 { margin-left: 12px; } .ms-auto { margin-left: auto; }
.me-1 { margin-right: 4px; } .me-2 { margin-right: 8px; } .me-3 { margin-right: 12px; } .me-4 { margin-right: 16px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.my-4 { margin-top: 16px; margin-bottom: 16px; }
.p-0 { padding: 0; } .p-2 { padding: 8px; } .p-3 { padding: 12px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; } .py-3 { padding-top: 12px; padding-bottom: 12px; } .py-4 { padding-top: 16px; padding-bottom: 16px; } .py-5 { padding-top: 24px; padding-bottom: 24px; }
.px-0 { padding-left: 0; padding-right: 0; } .px-3 { padding-left: 12px; padding-right: 12px; }
.pt-3 { padding-top: 12px; }
.pb-0 { padding-bottom: 0; }

.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.fw-medium { font-weight: 500; }
.fw-normal { font-weight: 400; }
.fs-3 { font-size: 1.5rem; } .fs-4 { font-size: 1.25rem; } .fs-5 { font-size: 1.1rem; } .fs-6 { font-size: 1rem; }
.small { font-size: .85em; }
.text-muted { color: var(--fg-3); }
.text-primary { color: var(--brand-2, #2563eb); }
.text-success { color: #16a34a; }
.text-danger  { color: #dc2626; }
.text-warning { color: #d97706; }
.text-info    { color: #2563eb; }
.text-white   { color: #fff; }
.text-dark    { color: var(--fg-1); }

.rounded { border-radius: var(--r-md, 8px); }
.rounded-circle { border-radius: 50%; }
.shadow-sm { box-shadow: var(--sh-sm, 0 1px 3px rgba(0,0,0,.05)); }
.shadow    { box-shadow: var(--sh-md, 0 4px 12px rgba(0,0,0,.08)); }
.border-0  { border: 0 !important; }
.border    { border: 1px solid var(--border, #e2e8f0); }
.border-top    { border-top: 1px solid var(--border); }
.border-bottom { border-bottom: 1px solid var(--border); }
.border-warning { border: 1px solid #f59e0b; }
.border-info    { border: 1px solid #2563eb; }
.border-danger  { border: 1px solid #dc2626; }
.bg-white { background: var(--bg-surface, #fff); }
.bg-light { background: var(--bg-2, #f5f7fa); }
.bg-primary { background: var(--brand-2, #2563eb); }
.bg-success { background: #d1fae5; color: #065f46; }
.bg-danger  { background: #fee2e2; color: #b91c1c; }
.bg-warning { background: #fef3c7; color: #92400e; }
.bg-info    { background: #dbeafe; color: #1e40af; }
.bg-secondary { background: var(--bg-2, #f5f7fa); color: var(--fg-2); }
.bg-opacity-10 { opacity: .9; }

/* ─── Cards ─── */
.card {
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--r-lg, 12px);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2, #f8fafc);
  font-weight: 600;
  color: var(--fg-1);
}
.card-header.bg-primary { background: var(--brand-2, #2563eb); color: #fff; }
.card-header.bg-success { background: #16a34a; color: #fff; }
.card-header.bg-danger  { background: #dc2626; color: #fff; }
.card-header.bg-warning { background: #f59e0b; color: #fff; }
.card-body  { padding: 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--bg-2); }
.card.h-100 { height: 100%; }
.shadow-sm.card, .card.shadow-sm { box-shadow: var(--sh-sm); }
.card.border-danger  { border-color: #dc2626; }
.card.border-warning { border-color: #f59e0b; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r-md, 8px);
  border: 1px solid transparent;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  background: var(--bg-2);
  color: var(--fg-1);
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  line-height: 1.2;
}
.btn:hover { filter: brightness(.97); }
.btn:focus { outline: 2px solid var(--brand-2, #2563eb); outline-offset: 1px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 20px; font-size: 16px; }
.btn-primary   { background: var(--brand-2, #2563eb); color: #fff; border-color: var(--brand-2, #2563eb); }
.btn-secondary { background: var(--bg-2, #f5f7fa); color: var(--fg-1); border-color: var(--border); }
.btn-success   { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn-danger    { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-warning   { background: #f59e0b; color: #fff; border-color: #f59e0b; }
.btn-info      { background: #0ea5e9; color: #fff; border-color: #0ea5e9; }
.btn-light     { background: #fff; color: var(--fg-1); border-color: var(--border); }
.btn-outline-primary   { background: transparent; color: var(--brand-2, #2563eb); border-color: var(--brand-2, #2563eb); }
.btn-outline-secondary { background: transparent; color: var(--fg-2); border-color: var(--border); }
.btn-outline-success   { background: transparent; color: #16a34a; border-color: #16a34a; }
.btn-outline-danger    { background: transparent; color: #dc2626; border-color: #dc2626; }
.btn-outline-warning   { background: transparent; color: #d97706; border-color: #d97706; }
.btn-outline-info      { background: transparent; color: #0ea5e9; border-color: #0ea5e9; }
.btn-outline-primary:hover, .btn-outline-success:hover, .btn-outline-danger:hover,
.btn-outline-warning:hover, .btn-outline-info:hover { color: #fff; }
.btn-outline-primary:hover { background: var(--brand-2, #2563eb); }
.btn-outline-secondary:hover { background: var(--bg-2); }
.btn-outline-success:hover { background: #16a34a; }
.btn-outline-danger:hover  { background: #dc2626; }
.btn-outline-warning:hover { background: #d97706; }
.btn-outline-info:hover    { background: #0ea5e9; }
.btn-group { display: inline-flex; gap: 4px; }

.btn-close {
  width: 28px; height: 28px; padding: 0;
  border: 0; background: transparent; cursor: pointer;
  font-size: 0;
  position: relative;
  border-radius: 50%;
  color: var(--fg-2);
}
.btn-close::before, .btn-close::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 14px; height: 2px; background: currentColor;
  transform-origin: center;
}
.btn-close::before { transform: translate(-50%,-50%) rotate(45deg); }
.btn-close::after  { transform: translate(-50%,-50%) rotate(-45deg); }
.btn-close:hover { background: rgba(0,0,0,.06); }
.btn-close-white { color: #fff; }
.btn-close-white:hover { background: rgba(255,255,255,.15); }

/* ─── Forms ─── */
.form-label { display: inline-block; margin-bottom: 6px; font-weight: 500; color: var(--fg-1); font-size: 14px; }
.form-control, .form-select {
  display: block; width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-surface, #fff);
  color: var(--fg-1);
  border: 1px solid var(--border, #d1d5db);
  border-radius: var(--r-md, 8px);
  box-sizing: border-box;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  padding-right: 36px;
}
.form-control:focus, .form-select:focus { outline: none; border-color: var(--brand-2, #2563eb); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.form-control:disabled { background: var(--bg-2); cursor: not-allowed; opacity: .7; }
.form-text { display: block; margin-top: 4px; font-size: 12px; color: var(--fg-3); }

.input-group { display: flex; align-items: stretch; width: 100%; }
.input-group > .form-control, .input-group > .form-select { flex: 1 1 auto; min-width: 0; }
.input-group > .form-control:not(:first-child), .input-group > .form-select:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.input-group > .form-control:not(:last-child),  .input-group > .form-select:not(:last-child)  { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .btn:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.input-group > .btn:not(:last-child)  { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group-text {
  display: flex; align-items: center;
  padding: 9px 12px;
  font-size: 14px;
  background: var(--bg-2);
  color: var(--fg-2);
  border: 1px solid var(--border);
  border-right: 0;
  border-top-left-radius: var(--r-md, 8px);
  border-bottom-left-radius: var(--r-md, 8px);
}

.form-check { display: flex; align-items: center; gap: 8px; padding: 0; }
.form-check-inline { display: inline-flex; margin-right: 16px; }
.form-check-input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.form-check-label { font-size: 14px; color: var(--fg-1); cursor: pointer; }
.form-switch { padding-left: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.form-switch .form-check-input { width: 36px; height: 20px; appearance: none; margin: 0; flex-shrink: 0; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; position: relative; cursor: pointer; transition: background .15s ease; }
.form-switch .form-check-input::before { content: ''; position: absolute; top: 1px; left: 1px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform .15s ease; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.form-switch .form-check-input:checked { background: var(--primary); border-color: var(--primary); }
.form-switch .form-check-input:checked::before { transform: translateX(16px); }

.invalid-feedback { display: block; margin-top: 4px; font-size: 12px; color: #dc2626; }

/* ─── Tables ─── */
.table {
  width: 100%; border-collapse: collapse;
  background: var(--bg-surface, #fff);
  font-size: 14px;
}
.table th, .table td {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.table thead th { background: var(--bg-2); font-weight: 600; color: var(--fg-1); border-top: 0; border-bottom: 1px solid var(--border); }
.table-bordered th, .table-bordered td { border: 1px solid var(--border); }
.table-striped tbody tr:nth-of-type(odd) { background: var(--bg-2); }
.table-hover tbody tr:hover { background: rgba(37,99,235,.04); }
.table-light { background: var(--bg-2); }
.table-secondary { background: var(--bg-2); }
.table-responsive { overflow-x: auto; }

/* ─── Alerts ─── */
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md, 8px);
  margin-bottom: 12px;
  font-size: 14px;
  border: 1px solid transparent;
}
.alert-info    { background: #eff6ff; color: #1e3a8a; border-color: #bfdbfe; }
.alert-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.alert-danger  { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-secondary { background: var(--bg-2); color: var(--fg-2); border-color: var(--border); }
.alert-link { color: inherit; text-decoration: underline; font-weight: 600; }

/* ─── Badges ─── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  font-size: 11px; font-weight: 600;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--fg-2);
}
.badge.bg-primary { background: var(--brand-2, #2563eb); color: #fff; }
.badge.bg-success { background: #16a34a; color: #fff; }
.badge.bg-danger  { background: #dc2626; color: #fff; }
.badge.bg-warning { background: #f59e0b; color: #fff; }
.badge.bg-info    { background: #0ea5e9; color: #fff; }
.badge.bg-secondary { background: var(--bg-2); color: var(--fg-2); border: 1px solid var(--border); }
.badge.bg-success-subtle { background: #d1fae5; color: #065f46; }
.badge.bg-warning-subtle { background: #fef3c7; color: #92400e; }
.badge.bg-danger-subtle  { background: #fee2e2; color: #b91c1c; }

/* ─── List group ─── */
.list-group { display: flex; flex-direction: column; border-radius: var(--r-md, 8px); overflow: hidden; border: 1px solid var(--border); margin-bottom: 12px; }
.list-group-item { padding: 10px 14px; background: var(--bg-surface); border-bottom: 1px solid var(--border); }
.list-group-item:last-child { border-bottom: 0; }

/* ─── Modal (Bootstrap markup) ─── */
.modal {
  display: none;
  position: fixed; inset: 0;
  z-index: 2000;
  padding: 20px;
  background: rgba(8,22,45,.55);
  backdrop-filter: blur(6px);
  align-items: center; justify-content: center;
  overflow-y: auto;
}
.modal.show { display: flex; }
.modal-dialog {
  width: 640px; max-width: 100%;
  margin: auto;
}
.modal-dialog.modal-lg { width: 800px; }
.modal-dialog.modal-sm { width: 480px; }
.modal-dialog-centered { display: flex; align-items: center; min-height: 100%; }
.modal-content {
  width: 100%;
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border);
  border-radius: var(--r-lg, 12px);
  box-shadow: var(--sh-lg, 0 12px 28px rgba(0,0,0,.18));
  max-height: 90vh; overflow-y: auto;
}
.modal-content.border-warning { border-color: #f59e0b; }
.modal-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header.bg-primary { background: var(--brand-2, #2563eb); color: #fff; border-bottom-color: var(--brand-2, #2563eb); }
.modal-header.bg-warning { background: #f59e0b; color: #fff; }
.modal-header.bg-danger  { background: #dc2626; color: #fff; }
.modal-title { flex: 1; font-size: 17px; font-weight: 600; margin: 0; }
.modal-body  { padding: 20px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ─── Accordion (Bootstrap markup) ─── */
.accordion { display: flex; flex-direction: column; gap: 6px; }
.accordion-item { border: 1px solid var(--border); border-radius: var(--r-md, 8px); overflow: hidden; }
.accordion-header { margin: 0; }
.accordion-button {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-2);
  color: var(--fg-1);
  border: 0;
  font-size: 14px; font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.accordion-button:not(.collapsed) { background: var(--brand-2, #2563eb); color: #fff; }
.accordion-button::after {
  content: '';
  margin-left: auto;
  width: 14px; height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  transition: transform .2s ease;
}
.accordion-button.collapsed::after { transform: rotate(-90deg); }
.accordion-collapse:not(.show) { display: none; }
.accordion-body { padding: 14px 16px; background: var(--bg-surface); }

/* ─── Spinner ─── */
.spinner-border {
  display: inline-block;
  width: 32px; height: 32px;
  border: 3px solid rgba(37,99,235,.2);
  border-top-color: var(--brand-2, #2563eb);
  border-radius: 50%;
  animation: kz-spin .8s linear infinite;
  vertical-align: middle;
}
@keyframes kz-spin { to { transform: rotate(360deg); } }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ─── Utilities used in legacy templates ─── */
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.h-100 { height: 100%; }
.w-100 { width: 100%; }
