/* Zackgo UI — shared enterprise feedback, loading, error, form polish */

/* ── Page fade-in ── */
.zg-page-enter {
  animation: zgPageEnter 0.35s ease-out both;
}
@keyframes zgPageEnter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ── Toast stack ── */
.zg-toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10050;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.zg-toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--zg-toast-bg, #06231B);
  color: var(--zg-toast-text, #fff);
  box-shadow: 0 12px 40px rgba(10, 18, 32, 0.28), 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 500;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.zg-toast.show {
  opacity: 1;
  transform: translateY(0);
}
.zg-toast.hide {
  opacity: 0;
  transform: translateY(8px);
}
.zg-toast__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}
.zg-toast__body {
  flex: 1;
  min-width: 0;
  white-space: pre-line;
}
.zg-toast__close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.55;
  cursor: pointer;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}
.zg-toast__close:hover { opacity: 1; background: rgba(255, 255, 255, 0.08); }
.zg-toast--success { --zg-toast-bg: #0F2A1A; border-color: rgba(34, 197, 94, 0.25); }
.zg-toast--success .zg-toast__icon { color: #22C55E; }
.zg-toast--error { --zg-toast-bg: #2A1215; border-color: rgba(239, 68, 68, 0.25); }
.zg-toast--error .zg-toast__icon { color: #EF4444; }
.zg-toast--warning { --zg-toast-bg: #2A2010; border-color: rgba(232, 160, 32, 0.3); }
.zg-toast--warning .zg-toast__icon { color: #E0B44C; }
.zg-toast--info .zg-toast__icon { color: #3B82F6; }
[data-theme="light"] .zg-toast {
  --zg-toast-bg: #FFFFFF;
  --zg-toast-text: #06231B;
  border-color: #E2E8F0;
  box-shadow: 0 12px 40px rgba(15, 27, 45, 0.12);
}
[data-theme="light"] .zg-toast--success { background: #F0FDF4; border-color: #BBF7D0; }
[data-theme="light"] .zg-toast--error { background: #FEF2F2; border-color: #FECACA; }
[data-theme="light"] .zg-toast--warning { background: #FFF8F0; border-color: rgba(232, 160, 32, 0.35); }

/* ── Confirm / prompt / info modals ── */
.zg-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10040;
  background: rgba(6, 14, 26, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s;
}
.zg-modal-overlay.open {
  opacity: 1;
  visibility: visible;
}
.zg-modal {
  width: 100%;
  max-width: 440px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-primary, #06231B);
  border-radius: 16px;
  border: 1px solid rgba(10, 10, 10, 0.08);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 24px 64px rgba(10, 10, 10, 0.18);
  padding: 24px;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.zg-modal-overlay.open .zg-modal {
  transform: none;
}
[data-theme="dark"] .zg-modal {
  background: rgba(20, 20, 20, 0.88);
  color: #F5F3EE;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 24px 64px rgba(0, 0, 0, 0.45);
}
.zg-modal__title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.zg-modal__body {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary, #4A5568);
  margin-bottom: 20px;
  white-space: pre-line;
}
[data-theme="dark"] .zg-modal__body { color: rgba(255, 255, 255, 0.65); }
.zg-modal__input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border, #E2E8F0);
  background: var(--input-bg, #fff);
  color: inherit;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 20px;
}
.zg-modal__input:focus {
  outline: 2px solid rgba(232, 160, 32, 0.45);
  outline-offset: 1px;
}
.zg-modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.zg-modal__btn {
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);
  transition: background 0.2s, border-color 0.2s, transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.zg-modal__btn:active { transform: scale(0.98); }
.zg-modal__btn--ghost {
  background: rgba(255, 255, 255, 0.5);
  border-color: var(--border, #E2E8F0);
  color: var(--text-secondary, #4A5568);
}
.zg-modal__btn--primary {
  background: linear-gradient(145deg, rgba(10, 10, 10, 0.94), rgba(15, 15, 15, 0.98));
  color: var(--btn-primary-text, #F5F3EE);
  border-color: rgba(255, 255, 255, 0.1);
}
.zg-modal__btn--danger {
  background: rgba(239, 68, 68, 0.92);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.12);
}
.zg-modal__btn--accent {
  background: linear-gradient(180deg, #FB923C 0%, #F97316 55%, #EA580C 100%);
  color: #FFFFFF;
  border-color: rgba(249, 115, 22, 0.4);
}

/* ── Error card ── */
.zg-error-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 28px;
  max-width: 480px;
  margin: 0 auto;
  border-radius: 16px;
  border: 1px solid var(--border, #E2E8F0);
  background: var(--surface, #fff);
}
[data-theme="dark"] .zg-error-card {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.08);
}
.zg-error-card__icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  background: rgba(239, 68, 68, 0.1);
  color: #EF4444;
}
.zg-error-card__title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
}
.zg-error-card__message {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted, #8892A4);
  margin-bottom: 8px;
}
.zg-error-card__id {
  font-size: 11px;
  font-family: ui-monospace, monospace;
  color: var(--text-muted, #8892A4);
  margin-bottom: 20px;
  opacity: 0.8;
}
.zg-error-card__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── Skeleton loaders ── */
.zg-skeleton-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0;
  animation: zgFadeIn 0.3s ease;
}
.zg-skeleton {
  background: linear-gradient(90deg,
    var(--zg-sk-base, rgba(15, 27, 45, 0.06)) 0%,
    var(--zg-sk-shine, rgba(15, 27, 45, 0.12)) 50%,
    var(--zg-sk-base, rgba(15, 27, 45, 0.06)) 100%);
  background-size: 200% 100%;
  animation: zgShimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
}
[data-theme="dark"] .zg-skeleton {
  --zg-sk-base: rgba(255, 255, 255, 0.04);
  --zg-sk-shine: rgba(255, 255, 255, 0.09);
}
.zg-skeleton--line { height: 14px; }
.zg-skeleton--title { height: 22px; width: 55%; }
.zg-skeleton--card { height: 88px; border-radius: 12px; }
.zg-skeleton--row { height: 48px; border-radius: 10px; }
.zg-skeleton--kpi { height: 120px; border-radius: 14px; }
.zg-skeleton-grid {
  display: grid;
  gap: 16px;
}
.zg-skeleton-grid--kpi {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.zg-skeleton-grid--table {
  gap: 8px;
}
.zg-loading-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 24px;
  color: var(--text-muted, #8892A4);
  font-size: 14px;
  font-weight: 500;
}
.zg-loading-inline__spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border, #E2E8F0);
  border-top-color: #E0B44C;
  border-radius: 50%;
  animation: zgSpin 0.65s linear infinite;
  flex-shrink: 0;
}
@keyframes zgShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes zgFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes zgSpin { to { transform: rotate(360deg); } }

/* ── Enhanced empty state ── */
.zg-empty-pro {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 32px;
  max-width: 440px;
  margin: 0 auto;
}
.zg-empty-pro__icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(232, 160, 32, 0.1);
  color: #E0B44C;
  margin-bottom: 20px;
}
.zg-empty-pro__title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}
.zg-empty-pro__subtitle {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted, #8892A4);
  margin-bottom: 24px;
}
.zg-empty-pro__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── Form validation ── */
.zg-field-error {
  font-size: 12px;
  color: #EF4444;
  margin-top: 6px;
  display: none;
}
.zg-field-error.visible { display: block; }
.zg-input-invalid {
  border-color: #EF4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}
.zg-required::after {
  content: ' *';
  color: #EF4444;
  font-weight: 600;
}
.zg-pwd-strength {
  height: 4px;
  border-radius: 2px;
  background: var(--border, #E2E8F0);
  margin-top: 8px;
  overflow: hidden;
}
.zg-pwd-strength__bar {
  height: 100%;
  width: 0;
  border-radius: 2px;
  transition: width 0.25s ease, background 0.25s;
}
.zg-pwd-strength__label {
  font-size: 11px;
  color: var(--text-muted, #8892A4);
  margin-top: 4px;
}

/* ── Button loading ── */
.zg-btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.75;
}
.zg-btn-loading::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: zgSpin 0.6s linear infinite;
  opacity: 0.7;
}

/* ── Table polish ── */
.zg-table-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted, #8892A4);
  font-size: 14px;
}
.zg-table-loading td {
  padding: 0 !important;
  border: none !important;
}

/* ── Micro-interactions ── */
.zg-hover-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.zg-hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg, 0 4px 24px rgba(0, 0, 0, 0.1));
}

/* ── Focus & a11y ── */
.zg-modal__btn:focus-visible,
.zg-toast__close:focus-visible,
.zg-empty-pro__actions button:focus-visible,
.zg-error-card__actions button:focus-visible {
  outline: 2px solid #E0B44C;
  outline-offset: 2px;
}

/* ── Mobile ── */
@media (max-width: 640px) {
  .zg-toast-stack {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
  .zg-modal { padding: 20px; }
  .zg-modal__actions { flex-direction: column-reverse; }
  .zg-modal__btn { width: 100%; text-align: center; }
}

/* Virtual table windowing */
.zg-vt-spacer { contain: strict; }
.zg-vt-window { contain: layout style; }
.zg-vt-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-mute, #7B869A);
  font-size: 13px;
}

/* Screen-reader only */
.zg-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* GPU-friendly transitions */
.zg-fade-in {
  animation: zg-fade-in 0.25s ease-out;
  will-change: opacity, transform;
}
@keyframes zg-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .zg-page-enter,
  .zg-skeleton,
  .zg-loading-inline__spinner,
  .zg-toast,
  .zg-fade-in { animation: none !important; transition-duration: 0.01ms !important; transform: none !important; }
}
