/**
 * Общие стили Alpine-таблиц (имитация DataTables: scroll, maximize, sorting).
 * Клик по строке — в page JS / макросе, не здесь.
 */
[x-cloak] {
  display: none !important;
}

.cursor-pointer {
  cursor: pointer;
}

/* bootstrap-select: inset outline (#333 / focus-ring) — чёрная рамка внутри поля */
.bootstrap-select .dropdown-toggle:focus,
.bootstrap-select > select.mobile-device:focus + .dropdown-toggle {
  outline: 0 !important;
  outline-offset: 0;
}

.alpine-table-scroll {
  overflow: auto;
  width: 100%;
  position: relative;
}

.alpine-table-scroll.is-processing {
  pointer-events: none;
  /* точки у верхнего края: на пустой таблице иначе некуда рисовать */
  min-height: 8rem;
}

.alpine-table-scroll.is-processing::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.55);
}

/* Три точки у шапки (один элемент + box-shadow) */
.alpine-table-scroll.is-processing::after {
  content: '';
  position: absolute;
  top: 1.15rem;
  left: 50%;
  z-index: 21;
  width: 0.5rem;
  height: 0.5rem;
  margin-left: -1.4rem;
  border-radius: 50%;
  background-color: #007bff;
  box-shadow: 1.15rem 0 0 rgba(0, 123, 255, 0.28), 2.3rem 0 0 rgba(0, 123, 255, 0.28);
  animation: alpine-processing-dots 0.9s ease-in-out infinite;
}

@keyframes alpine-processing-dots {
  0%, 100% {
    background-color: #007bff;
    box-shadow: 1.15rem 0 0 rgba(0, 123, 255, 0.28), 2.3rem 0 0 rgba(0, 123, 255, 0.28);
  }
  33% {
    background-color: rgba(0, 123, 255, 0.28);
    box-shadow: 1.15rem 0 0 #007bff, 2.3rem 0 0 rgba(0, 123, 255, 0.28);
  }
  66% {
    background-color: rgba(0, 123, 255, 0.28);
    box-shadow: 1.15rem 0 0 rgba(0, 123, 255, 0.28), 2.3rem 0 0 #007bff;
  }
}

@media (prefers-reduced-motion: reduce) {
  .alpine-table-scroll.is-processing::after {
    animation: none;
  }
}

.card.maximized-card {
  display: flex;
  flex-direction: column;
}

.card.maximized-card > .card-body {
  flex: 1 1 auto;
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.card.maximized-card .alpine-table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none !important;
}

/* Bootstrap 4 .card — flex-колонка. min-height:auto не даёт CardWidget.slideUp
   сжать body/footer (контент виден до display:none). overflow:auto на секции
   это обходит; футер и обычный card-body — нет. */
.content-wrapper .card > .card-body,
.content-wrapper .card > .card-footer {
  min-height: 0;
}

.content-wrapper .card.card-widget-busy > .card-body,
.content-wrapper .card.card-widget-busy > .card-footer {
  overflow: hidden;
  min-height: 0 !important;
}

/* Sticky-шапка внутри scroll-контейнера (как AdminLTE .table-head-fixed) */
.alpine-table-scroll > table thead tr:first-child th,
.alpine-table-scroll > table.table-head-fixed thead tr:nth-child(1) th {
  background-color: #ffffff;
  border-bottom: 0;
  box-shadow: inset 0 1px 0 #dee2e6, inset 0 -1px 0 #dee2e6;
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 10;
}

table.dataTable thead th.sorting,
table.dataTable thead th.sorting_asc,
table.dataTable thead th.sorting_desc {
  cursor: pointer;
  user-select: none;
}

/* Live-обновление строк списка заявок (WS refetch) */
tr.req-row-anim-enter {
  animation: req-row-enter 0.55s ease-out both;
  animation-delay: var(--req-delay, 0ms);
}
tr.req-row-anim-highlight {
  animation: req-row-highlight 4.5s ease-out both;
}
@keyframes req-row-enter {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes req-row-highlight {
  0% { background-color: #fff3cd; box-shadow: inset 0 0 0 2px rgba(255, 193, 7, 0.45); }
  35% { background-color: #fff8e1; box-shadow: inset 0 0 0 1px rgba(255, 193, 7, 0.25); }
  100% { background-color: transparent; box-shadow: none; }
}

/* Sticky-баннер remote-lock / устаревшие данные (Alpine collab) */
.protocol-remote-lock,
.reduct-remote-lock,
.requisition-remote-lock {
  position: sticky;
  top: calc(3.5rem + 1px);
  z-index: 1020;
  border: 1px solid #ffc107;
  background: #fff8e1;
  color: #856404;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: 0.25rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.protocol-remote-lock.protocol-deleted {
  border-color: #f5c6cb;
  background: #f8d7da;
  color: #721c24;
}

.protocol-page-frozen .protocol-frozen-inert {
  pointer-events: none;
  opacity: 0.65;
}

/* Полноэкранная блокировка после logout / истечения сессии */
.app-session-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.42);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.app-session-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

body.app-session-locked {
  overflow: hidden;
}

.app-session-overlay-panel {
  width: 100%;
  max-width: 22.5rem;
  padding: 2rem 1.75rem 1.5rem;
  border-radius: 1.15rem;
  background: #fff;
  text-align: center;
  transform: translateY(0.5rem) scale(0.98);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.app-session-overlay.is-visible .app-session-overlay-panel {
  transform: none;
  opacity: 1;
}

.app-session-overlay-title {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #1f2d3d;
}

.app-session-overlay-text {
  margin: 0 0 1.35rem;
  font-size: 0.95rem;
  line-height: 1.45;
  color: #6c757d;
  white-space: pre-line;
}

.app-session-overlay-text.text-danger {
  color: #c82333 !important;
}

.app-session-conn {
  position: relative;
  width: 5.5rem;
  height: 5.5rem;
  margin: 0 auto 1.25rem;
  overflow: hidden;
}

.app-session-conn-ring {
  position: absolute;
  inset: 0.35rem;
  border: 2px solid rgba(23, 162, 184, 0.22);
  border-radius: 50%;
  animation: app-session-conn-ring 2.4s ease-out infinite;
}

.app-session-conn-ring:nth-child(2) {
  animation-delay: 0.8s;
}

.app-session-conn-ring:nth-child(3) {
  animation-delay: 1.6s;
}

.app-session-conn-mark {
  position: absolute;
  inset: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(180deg, #e8f8fb 0%, #d4f1f6 100%);
  color: #17a2b8;
  box-shadow: 0 0.35rem 1rem rgba(23, 162, 184, 0.18);
}

.app-session-conn-mark i {
  font-size: 1.35rem;
  animation: app-session-conn-wifi 2.4s ease-in-out infinite;
}

.app-session-overlay.is-checking .app-session-conn-ring {
  animation-duration: 1.2s;
  border-color: rgba(23, 162, 184, 0.4);
}

.app-session-overlay.is-checking .app-session-conn-mark {
  background: linear-gradient(180deg, #d6f4f8 0%, #bfeaf2 100%);
}

.app-session-overlay.is-checking .app-session-conn-mark i {
  animation-duration: 1.2s;
}

.app-session-overlay.is-error .app-session-conn-ring {
  animation: none;
  opacity: 0.28;
  border-color: rgba(200, 35, 51, 0.28);
}

.app-session-overlay.is-error .app-session-conn-mark {
  background: linear-gradient(180deg, #fdecee 0%, #f8d7da 100%);
  color: #c82333;
  box-shadow: 0 0.35rem 1rem rgba(200, 35, 51, 0.12);
}

.app-session-overlay.is-error .app-session-conn-mark i {
  animation: none;
}

@keyframes app-session-conn-ring {
  0% {
    transform: scale(0.72);
    opacity: 0.7;
  }
  100% {
    transform: scale(1.18);
    opacity: 0;
  }
}

@keyframes app-session-conn-wifi {
  0%, 100% {
    opacity: 0.45;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-1px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-session-overlay,
  .app-session-overlay-panel {
    transition: none;
  }

  .app-session-conn-ring,
  .app-session-conn-mark i {
    animation: none;
  }

  .app-session-overlay.is-visible .app-session-overlay-panel {
    transform: none;
  }
}
