/* RBS Forum R6 - unified, non-invasive modal design.
   Covers all Bootstrap modal markup, including modals inserted later via AJAX.
   Do NOT alter IDs, input values, payment/RCON callbacks or engine modules. */

/* R1 accidentally widened every dialog by overriding Bootstrap max-width.
   Restore an intentional scale, then make specialty dialogs wider. */
body.rbs-modern .modal .modal-dialog {
  width: min(560px, calc(100vw - 40px));
  max-width: calc(100vw - 40px);
  margin: clamp(12px, 3vh, 35px) auto;
  box-sizing: border-box;
}
body.rbs-modern .modal .modal-dialog.modal-lg {
  width: min(920px, calc(100vw - 40px));
  max-width: calc(100vw - 40px);
}
body.rbs-modern .modal.rbs-detail-modal .modal-dialog.modal-lg {
  width: min(820px, calc(100vw - 40px));
}
/* R2 player cards and R4 stat panes have their own tested width rules.
   Refrain from overriding their important values. */

/* Height-aware modal layout. Scroll CONTENT only, keep title and close control accessible. */
body.rbs-modern .modal .modal-content {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-height: calc(100vh - 28px);
  max-height: calc(100dvh - 28px);
  color: #e7effa;
  background: #1e2a39;
  border: 1px solid rgba(142, 168, 198, .29);
  border-radius: 15px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, .48);
}
body.rbs-modern .modal .modal-header {
  position: relative;
  flex: 0 0 auto;
  min-height: 64px;
  padding: 17px 60px 15px 22px;
  border-bottom: 1px solid rgba(151, 182, 210, .17);
  background: #213044;
  border-radius: 14px 14px 0 0;
}
body.rbs-modern .modal .modal-header h4.modal-title,
body.rbs-modern .modal .modal-header h5.modal-title,
body.rbs-modern .modal .modal-header h6.modal-title {
  color: #f1f7ff;
  font-size: 18px;
  font-weight: 750;
  line-height: 1.35;
  overflow-wrap: anywhere;
  margin: 0;
}
body.rbs-modern .modal .modal-header .close {
  position: absolute;
  right: 12px;
  top: 12px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  border: 1px solid rgba(164, 194, 228, .28);
  border-radius: 10px;
  background: #2b3c53;
  color: #f1f7ff;
  opacity: 1;
  line-height: 1;
  text-shadow: none;
}
body.rbs-modern .modal .modal-header .close:hover,
body.rbs-modern .modal .modal-header .close:focus-visible {
  background: #3a516f;
  color: white;
  outline: 2px solid rgba(140, 193, 255, .7);
  outline-offset: 1px;
}
body.rbs-modern .modal .modal-body {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-color: #516b8b #1e2a39;
  scrollbar-width: thin;
  padding: 19px 22px 22px;
  line-height: 1.55;
}
body.rbs-modern .modal .modal-footer {
  flex: 0 0 auto;
  min-width: 0;
  padding: 14px 22px;
  border-top: 1px solid rgba(151, 182, 210, .17);
}
body.rbs-modern .modal .modal-body img,
body.rbs-modern .modal .modal-body iframe,
body.rbs-modern .modal .modal-body video { max-width: 100%; }
body.rbs-modern .modal .modal-body pre { max-width: 100%; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
body.rbs-modern .modal .modal-body p { margin-bottom: 8px; }
body.rbs-modern .modal .modal-body .row > [class*="col-"] { min-width: 0; }
body.rbs-modern .modal .modal-body :is(input, textarea, select).form-control {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
body.rbs-modern .modal .modal-body input.form-control,
body.rbs-modern .modal .modal-body select.form-control,
body.rbs-modern .modal .modal-body textarea.form-control {
  background: #182431;
  border: 1px solid #415572;
  color: #e3efff;
  border-radius: 9px;
}
body.rbs-modern .modal .modal-body input.form-control:focus,
body.rbs-modern .modal .modal-body select.form-control:focus,
body.rbs-modern .modal .modal-body textarea.form-control:focus {
  background: #1b2b3d;
  border-color: #80b7f3;
  box-shadow: 0 0 0 2px rgba(128, 183, 243, .17);
}
body.rbs-modern .modal .modal-body .table-responsive {
  max-width: 100%;
  overflow-x: auto;
  border-radius: 10px;
  -webkit-overflow-scrolling: touch;
}
body.rbs-modern .modal .modal-body .table-responsive > table.table { margin-bottom: 0; }
body.rbs-modern .modal .modal-body .table-responsive > table.table.rbs-dense-modal-table {
  min-width: 660px;
  width: 100%;
  table-layout: auto;
}
/* When the first heading is "#", do not waste a third of the table on its index. */
body.rbs-modern .modal .modal-body .table-responsive > table.table.rbs-indexed-modal-table tr > :first-child {
  width: 52px !important;
  min-width: 52px !important;
  max-width: 70px;
}
body.rbs-modern .modal .modal-body .table.table-bordered > tbody > tr > td,
body.rbs-modern .modal .modal-body .table.table-bordered > thead > tr > td {
  padding: 10px 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  vertical-align: middle;
}
body.rbs-modern .modal .modal-body .btn {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Two-column key/value details: bans, mutes, support appeal and quick ban lookup. */
body.rbs-modern .rbs-detail-modal .modal-body .table-responsive > table.table {
  width: 100%;
  min-width: 0 !important;
  table-layout: fixed;
}
body.rbs-modern .rbs-detail-modal .modal-body .table-responsive > table.table > tbody > tr > td:first-child {
  width: 34%;
  min-width: 0;
  color: #c1d2e7;
  font-weight: 650;
}
body.rbs-modern .rbs-detail-modal .modal-body .table-responsive > table.table > tbody > tr > td:last-child {
  width: 66%;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: normal;
}
body.rbs-modern .rbs-detail-modal .modal-body .table-responsive > table.table > tbody > tr > td p:last-child {
  margin: 0;
}
body.rbs-modern .rbs-detail-modal .modal-body .table-responsive > table.table > tbody > tr > td .btn {
  margin: 4px 4px 4px 0;
}
body.rbs-modern .rbs-detail-modal td.rbs-permanent-date-cell {
  position: relative;
}
body.rbs-modern .rbs-detail-modal td.rbs-permanent-date-cell > input.rbs-permanent-date-input:not(:focus) {
  color: transparent !important;
}
body.rbs-modern .rbs-detail-modal td.rbs-permanent-date-cell:not(:focus-within)::after {
  content: "Бессрочно — нажмите для изменения";
  display: block;
  position: absolute;
  left: 24px;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #dceaff;
  font-size: 13px;
  line-height: 1.35;
}

/* jquery-confirm plugin is separate from Bootstrap modal; adjust only its surface. */
body.rbs-modern .jconfirm .jconfirm-box {
  max-width: calc(100vw - 28px);
  border-radius: 14px;
  border: 1px solid rgba(148, 177, 211, .26);
  background: #1e2a39;
  color: #e6f0fc;
  box-shadow: 0 26px 75px rgba(0,0,0,.50);
}
body.rbs-modern .jconfirm .jconfirm-box .jconfirm-title,
body.rbs-modern .jconfirm .jconfirm-box .jconfirm-content { color: #e6f0fc; }
body.rbs-modern .jconfirm .jconfirm-box .jconfirm-content {
  max-height: min(65vh, 550px);
  overflow-y: auto;
  overflow-wrap: anywhere;
}

@media (max-width: 767.98px) {
  body.rbs-modern .modal .modal-dialog,
  body.rbs-modern .modal .modal-dialog.modal-lg,
  body.rbs-modern .modal.rbs-detail-modal .modal-dialog.modal-lg {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    margin: 10px auto;
  }
  body.rbs-modern .modal .modal-content {
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    border-radius: 12px;
  }
  body.rbs-modern .modal .modal-header {
    min-height: 55px;
    padding: 14px 55px 12px 14px;
    border-radius: 11px 11px 0 0;
  }
  body.rbs-modern .modal .modal-header .close { top: 9px; right: 9px; }
  body.rbs-modern .modal .modal-body { padding: 12px 14px 16px; }
  body.rbs-modern .modal .modal-footer { padding: 12px 14px; }
  body.rbs-modern .modal .modal-body .table.table-bordered > tbody > tr > td,
  body.rbs-modern .modal .modal-body .table.table-bordered > thead > tr > td { padding: 9px 10px; }
  body.rbs-modern .modal .modal-body .table-responsive > table.table.rbs-dense-modal-table { min-width: 590px; }
  body.rbs-modern .modal .modal-body .input-group { min-width: 0; flex-wrap: wrap; }
  body.rbs-modern .modal .modal-body .input-group > .form-control { min-width: 0; }
}
@media (max-width: 575.98px) {
  body.rbs-modern .rbs-detail-modal .modal-body .table-responsive { border: 0; }
  body.rbs-modern .rbs-detail-modal .modal-body .table-responsive > table.table,
  body.rbs-modern .rbs-detail-modal .modal-body .table-responsive > table.table > tbody,
  body.rbs-modern .rbs-detail-modal .modal-body .table-responsive > table.table > tbody > tr,
  body.rbs-modern .rbs-detail-modal .modal-body .table-responsive > table.table > tbody > tr > td {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
  }
  body.rbs-modern .rbs-detail-modal .modal-body .table-responsive > table.table > tbody > tr {
    margin: 0 0 8px;
    border: 1px solid rgba(158,184,217,.18);
    border-radius: 8px;
    overflow: hidden;
  }
  body.rbs-modern .rbs-detail-modal .modal-body .table-responsive > table.table > tbody > tr > td:first-child {
    padding: 8px 10px 4px;
    border: 0;
    background: #25374a;
    font-size: 12px;
  }
  body.rbs-modern .rbs-detail-modal .modal-body .table-responsive > table.table > tbody > tr > td:last-child {
    padding: 7px 10px 11px;
    border: 0;
    font-size: 13px;
  }
  body.rbs-modern .rbs-detail-modal td.rbs-permanent-date-cell:not(:focus-within)::after {
    left: 23px; font-size: 12px;
  }
  body.rbs-modern .modal .modal-body .btn { width: 100%; margin: 4px 0; }
  body.rbs-modern .modal .modal-body .table-responsive > table.table.rbs-dense-modal-table .btn {
    width: auto;
    margin: 2px 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  body.rbs-modern .modal, body.rbs-modern .modal-dialog { transition: none !important; }
}
