/**
 * Компоненты операторского UI — карточки, кнопки, формы, табы, loading, empty.
 * После wesp-zootech-layout.css
 */

/* —— Section —— */
.zt-section {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--zt-radius-lg);
  box-shadow: var(--shadow-soft);
  padding: var(--zt-space-4);
  margin-bottom: var(--zt-space-4);
}

.zt-section__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--zt-space-3);
  margin-bottom: var(--zt-space-3);
  flex-wrap: wrap;
}

.zt-section__title {
  display: flex;
  align-items: center;
  gap: var(--zt-space-2);
  font-size: var(--zt-font-section);
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.zt-section__title i {
  color: var(--primary-color);
  font-size: 1.1rem;
}

.zt-section__subtitle {
  font-size: var(--zt-font-body);
  color: var(--muted);
  margin: 0.25rem 0 0;
}

.zt-section__actions {
  display: flex;
  align-items: center;
  gap: var(--zt-space-2);
  flex-shrink: 0;
}

/* —— Card —— */
.zt-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--zt-radius-lg);
  padding: var(--zt-space-4);
  box-shadow: var(--shadow-soft);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.zt-card--interactive {
  cursor: pointer;
}

.zt-card--interactive:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-soft), 0 0 0 2px rgba(var(--primary-rgb), 0.18);
}

.zt-card--dashed {
  border-style: dashed;
  border-color: var(--border-light);
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--zt-space-3);
}

.zt-card--stat {
  border-left: 3px solid var(--primary-color);
  padding: var(--zt-space-3) var(--zt-space-4);
}

.zt-card-grid {
  display: grid;
  gap: var(--zt-space-3);
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Legacy aliases */
.component-card,
.dispenser-card,
.consumption-block .zt-card {
  /* migrated pages use zt-card; keep hooks for gradual migration */
}

/* —— Loading placeholder —— */
.zt-loading-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--zt-space-2);
  min-height: 8rem;
  padding: var(--zt-space-3) 0;
}

.zt-loading-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--zt-space-2);
}

.zt-loading-list.dashboard-list-skeleton--exit,
.dashboard-list-skeleton--exit {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}

.zt-card--loading {
  pointer-events: none;
  min-height: 5.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--zt-space-2);
  animation: zt-card-pulse 1.6s ease-in-out infinite;
}

@keyframes zt-card-pulse {
  0%,
  100% {
    border-color: var(--border-light);
    opacity: 1;
  }
  50% {
    border-color: rgba(var(--primary-rgb), 0.35);
    opacity: 0.92;
  }
}

.zt-spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-light);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: zt-spin 0.7s linear infinite;
}

.zt-spinner--lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

@keyframes zt-spin {
  to {
    transform: rotate(360deg);
  }
}

.zt-loading-caption {
  font-size: var(--zt-font-caption);
  color: var(--muted);
  margin: 0;
}

.zt-loading-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--zt-space-3);
  padding: var(--zt-space-5);
  min-height: 12rem;
}

/* —— Tabs —— */
.zt-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--zt-space-1);
  margin-bottom: var(--zt-space-3);
}

.zt-tab,
.fa-tab-btn.period-btn {
  border: 1px solid var(--border-light);
  background: transparent;
  border-radius: var(--zt-radius-sm);
  padding: 0.45rem 0.85rem;
  font-size: var(--zt-font-body);
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
    color var(--transition);
  min-height: var(--zt-btn-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.zt-tab:hover,
.fa-tab-btn:not(.active):hover {
  background: rgba(var(--primary-rgb), 0.06);
  border-color: rgba(var(--primary-rgb), 0.25);
}

.zt-tab.active,
.zt-tab--active,
.fa-tab-btn.active,
.period-btn.active {
  background: var(--gradient-blue) !important;
  border-color: transparent !important;
  color: #fff !important;
}

/* —— Empty state —— */
.zt-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--zt-space-5) var(--zt-space-4);
  color: var(--muted);
}

.zt-empty__icon {
  font-size: 2.5rem;
  margin-bottom: var(--zt-space-3);
  opacity: 0.45;
}

.zt-empty__title {
  font-size: var(--zt-font-section);
  font-weight: 600;
  color: var(--text);
  margin: 0 0 var(--zt-space-1);
}

.zt-empty__hint {
  font-size: var(--zt-font-body);
  margin: 0;
  max-width: 28rem;
}

/* —— Inline notices & toasts (единый вид подсказок и уведомлений) —— */
.zt-notice {
  display: none;
  margin: 0;
  padding: 0.75rem 1rem;
  font-size: var(--zt-font-body);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-light);
  border: 1px solid var(--border-light);
  border-radius: var(--zt-radius-md);
  border-left-width: 3px;
  border-left-style: solid;
  box-shadow: var(--box-shadow);
}

.zt-notice.is-visible,
.zt-notice--static {
  display: block;
}

.zt-notice--info {
  border-left-color: var(--primary-color);
}

.zt-notice--success {
  border-left-color: var(--success-color);
  background: rgba(16, 185, 129, 0.08);
}

.zt-notice--warning {
  border-left-color: var(--warning-color);
  background: rgba(245, 158, 11, 0.1);
}

.zt-notice--error {
  border-left-color: var(--danger-color);
  background: rgba(239, 68, 68, 0.08);
}

.zt-notice__p {
  margin: 0 0 0.65rem;
}

.zt-notice__p:last-child {
  margin-bottom: 0;
}

.zt-notice__p strong {
  font-weight: 600;
  color: var(--text);
}

html[data-theme="dark"] .zt-notice {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text);
  box-shadow: none;
}

html[data-theme="dark"] .zt-notice--success {
  background: rgba(16, 185, 129, 0.12);
}

html[data-theme="dark"] .zt-notice--warning {
  background: rgba(245, 158, 11, 0.12);
}

html[data-theme="dark"] .zt-notice--error {
  background: rgba(239, 68, 68, 0.12);
}

/* —— Bottom-center toast (Yandex Music style) —— */
@keyframes wesp-zt-toast-enter {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes wesp-zt-toast-exit {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes wesp-zt-toast-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes wesp-zt-toast-fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.wesp-zt-toast-host {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 6000;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: min(28rem, calc(100vw - 2rem));
}

.wesp-zt-toast {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  width: max-content;
  max-width: min(28rem, calc(100vw - 2rem));
  min-height: 40px;
  padding: 0.45rem 0.55rem 0.45rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 12, 14, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
  animation: wesp-zt-toast-enter 280ms ease-out both;
}

.wesp-zt-toast.is-exiting {
  animation: wesp-zt-toast-exit 220ms ease-in both;
}

@media (prefers-reduced-motion: reduce) {
  .wesp-zt-toast {
    animation: wesp-zt-toast-fade-in 200ms ease-out both;
  }

  .wesp-zt-toast.is-exiting {
    animation: wesp-zt-toast-fade-out 180ms ease-in both;
  }
}

.wesp-zt-toast__accent {
  flex-shrink: 0;
  width: 0.5rem;
  height: 0.5rem;
  align-self: center;
  border-radius: 50%;
  background: var(--success-color);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.45);
}

.wesp-zt-toast--error .wesp-zt-toast__accent {
  background: var(--danger-color);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.45);
}

.wesp-zt-toast--warning .wesp-zt-toast__accent {
  background: var(--warning-color);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.45);
}

.wesp-zt-toast__message {
  flex: 0 1 auto;
  min-width: 0;
  margin: 0;
  padding-right: 0.15rem;
  font-size: 0.9375rem;
  line-height: 1.35;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wesp-zt-toast--multiline .wesp-zt-toast__message {
  white-space: normal;
}

.wesp-zt-toast__message strong {
  font-weight: 600;
  color: #fff;
}

.wesp-zt-toast__close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.wesp-zt-toast__close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

html[data-theme="light"] .wesp-zt-toast {
  background: rgba(30, 30, 34, 0.9);
  border-color: rgba(255, 255, 255, 0.12);
}

html[data-theme="light"] .wesp-zt-toast__message {
  color: rgba(255, 255, 255, 0.92);
}

/* —— Notification center FAB (bottom-left) —— */
.wesp-zt-notify-fab {
  position: fixed;
  left: max(20px, calc(env(safe-area-inset-left, 0px) + 16px));
  bottom: max(24px, calc(env(safe-area-inset-bottom, 0px) + 20px));
  z-index: 5500;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  background: rgba(12, 12, 14, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.wesp-zt-notify-fab:hover {
  transform: scale(1.04);
}

.wesp-zt-notify-fab:focus-visible {
  outline: 2px solid rgba(var(--primary-rgb), 0.85);
  outline-offset: 2px;
}

.wesp-zt-notify-fab__glyph {
  font-family: Inter, Arial, Helvetica, "DejaVu Sans", sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  transform: translateY(0.5px);
}

.wesp-zt-notify-fab__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px rgba(12, 12, 14, 0.95);
}

.wesp-zt-notify-fab__badge[hidden] {
  display: none !important;
}

/* —— Button grid (modals) —— */
.zt-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--zt-space-2);
}

@media (max-width: 480px) {
  .zt-btn-grid {
    grid-template-columns: 1fr;
  }
}

/* —— Form grid —— */
.zt-form-grid {
  display: grid;
  gap: var(--zt-space-3);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.zootech-app-body .form-label,
.zt-section .form-label {
  font-size: var(--zt-font-caption);
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

/* —— Bootstrap overrides (operator pages) —— */
.zootech-app-body .btn {
  min-height: var(--zt-btn-height);
  padding: 0.45rem 1rem;
  border-radius: var(--zt-radius-md);
  font-weight: 500;
  font-size: var(--zt-font-body);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--zt-space-1);
  transition: transform var(--transition), filter var(--transition),
    background var(--transition), border-color var(--transition);
}

.zootech-app-body .btn:active:not(:disabled) {
  transform: scale(0.98);
}

.zootech-app-body .btn:focus-visible {
  outline: none;
  box-shadow: var(--zt-focus-ring);
}

.zootech-app-body .btn-primary {
  background: var(--gradient-blue) !important;
  border: none !important;
  color: #fff !important;
}

.zootech-app-body .btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.zootech-app-body .btn-success {
  background: var(--success-color) !important;
  border-color: var(--success-color) !important;
  color: #fff !important;
}

.zootech-app-body .btn-success:hover:not(:disabled) {
  filter: brightness(1.05);
}

.zootech-app-body .btn-secondary {
  background: var(--field) !important;
  border-color: var(--border-light) !important;
  color: var(--text) !important;
}

.zootech-app-body .btn-outline-primary {
  color: var(--primary-color) !important;
  border-color: var(--primary-color) !important;
}

.zootech-app-body .btn-outline-primary:hover:not(:disabled) {
  background: rgba(var(--primary-rgb), 0.08) !important;
}

.zootech-app-body .btn-outline-secondary {
  color: var(--text) !important;
  border-color: var(--border-light) !important;
}

.zootech-app-body .btn-outline-danger {
  color: var(--danger-color) !important;
  border-color: rgba(239, 68, 68, 0.5) !important;
}

.zootech-app-body .btn-outline-success {
  color: var(--success-color) !important;
  border-color: rgba(16, 185, 129, 0.5) !important;
}

.zootech-app-body .btn-outline-success:hover:not(:disabled) {
  background: rgba(16, 185, 129, 0.1) !important;
}

.zootech-app-body .form-control,
.zootech-app-body .form-select {
  min-height: var(--zt-btn-height);
  border-radius: var(--zt-radius-md);
  border-color: var(--border-light);
  font-size: var(--zt-font-body);
}

.zootech-app-body .form-control:focus,
.zootech-app-body .form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

/* Magic / modern btn aliases */
.zootech-app-body .magic-button,
.zootech-app-body .modern-btn.btn-primary-modern,
.zootech-app-body .btn-primary-modern {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--zt-space-1);
  padding: 0.55rem 1.25rem;
  font-weight: 600;
  color: #fff;
  background: var(--gradient-blue);
  border: none;
  border-radius: var(--zt-radius-md);
  cursor: pointer;
  min-height: var(--zt-btn-height);
  box-shadow: var(--shadow-soft);
}

.zootech-app-body .magic-button:hover {
  filter: brightness(1.06);
}

/* Recipe editor — квадратные icon-кнопки в шапке */
#recipeEdit .recipe-edit-header-icon-btn {
  width: 2.5rem;
  height: 2.5rem;
  min-width: 2.5rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--zt-radius-md);
}

#recipeEdit .recipe-section-toolbar > .btn-primary,
#recipeEdit .recipe-form-footer-actions .btn-primary {
  min-height: var(--zt-btn-height);
  padding: 0.45rem 1rem;
  font-weight: 600;
}

#recipeEdit .recipe-save-exit-btn {
  min-width: 11rem;
}

@keyframes zt-reveal {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Recipes boot overlay — только зона контента, navbar остаётся виден */
#wesp-recipes-boot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  z-index: 900;
  background: var(--bg-page);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

#wesp-recipes-boot.wesp-recipes-boot--hide {
  opacity: 0;
}

html[data-theme="dark"] #wesp-recipes-boot {
  background: var(--bg-page);
}

#wesp-recipes-boot .wesp-logo-loader--embedded {
  width: min(480px, 90vw);
  height: min(222px, 36vh);
}

/* Gray scale legacy (reports) */
:root {
  --gray-50: var(--bg-light);
  --gray-100: #f3f4f6;
  --gray-200: var(--border-light);
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: var(--text-muted);
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: var(--text-dark);
  --white: var(--surface);
}

html[data-theme="dark"] {
  --gray-50: var(--bg-page);
  --gray-100: var(--surface);
  --gray-200: #2a3036;
  --gray-300: var(--field);
  --gray-400: var(--muted);
  --gray-500: #b8c0c8;
  --gray-600: #d0d4d8;
  --gray-700: #e8eaec;
  --gray-800: #f0f4f8;
  --gray-900: var(--text);
  --white: var(--surface);
}

@media (max-width: 768px) {
  .zootech-app-body .btn {
    min-height: var(--zt-btn-height-touch);
  }
}

@media (prefers-reduced-motion: reduce) {
  .zt-card--loading {
    animation: none;
  }
  .zt-spinner {
    animation: none;
    border-top-color: var(--primary-color);
  }
}
