/*
 * animations.css  —  Glassmorphism Motion System
 * Auth screen, dashboard transitions, card stagger, micro-interactions.
 */

/* ════════════════════════════════════════
   AUTH SCREEN
════════════════════════════════════════ */

#auth-screen {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: opacity 1.1s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 1.1s;
}

#auth-screen.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#auth-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* Subtle noise texture */
.auth-scanlines {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px;
}

/* ── Auth content block ────────────────── */
.auth-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 36px;
  animation: auth-enter 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes auth-enter {
  from { opacity: 0; transform: translateY(32px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Logo + title ──────────────────────── */
.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.auth-icon {
  animation: auth-float 7s ease-in-out infinite;
  filter: drop-shadow(0 0 30px rgba(56,189,248,0.4)) drop-shadow(0 0 60px rgba(167,139,250,0.2));
  transition: filter 0.3s;
}

@keyframes auth-float {
  0%, 100% { transform: translateY(0)    rotate(0deg); }
  30%       { transform: translateY(-10px) rotate(3deg); }
  65%       { transform: translateY(-4px)  rotate(-2deg); }
}

.auth-title {
  font-family: var(--font-display);
  font-size: clamp(60px, 10vw, 120px);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.01em;
  text-align: center;
  color: var(--text-primary);
}

.auth-title span {
  display: block;
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-violet) 50%, var(--accent-teal) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-size: 200% auto;
  animation: gradient-flow 4s ease-in-out infinite alternate;
}

@keyframes gradient-flow {
  0%   { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

.auth-subtitle {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.32em;
  color: var(--text-muted);
  text-transform: uppercase;
  text-align: center;
  animation: auth-enter 1.2s 0.2s both;
}

/* ── Glass card around form ────────────── */
.auth-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 360px;
  padding: 32px 32px 28px;
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--r-xl);
  box-shadow:
    0 24px 64px rgba(0,0,0,0.4),
    0 0 0 1px rgba(255,255,255,0.03) inset,
    inset 0 1px 0 rgba(255,255,255,0.1);
  animation: auth-enter 1.2s 0.15s both;
  position: relative;
  overflow: hidden;
}

/* Inner shimmer */
.auth-form::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(56,189,248,0.5), rgba(167,139,250,0.5), transparent);
  animation: shine 3s ease-in-out infinite;
}

@keyframes shine {
  0%   { opacity: 0.5; transform: scaleX(0.5); }
  50%  { opacity: 1;   transform: scaleX(1); }
  100% { opacity: 0.5; transform: scaleX(0.5); }
}

.input-wrapper {
  position: relative;
  width: 100%;
}

#password-input {
  width: 100%;
  background: rgba(4, 5, 15, 0.85);
  border: 1.5px solid rgba(56,189,248,0.6);
  border-radius: var(--r-md);
  color: #f0f4ff;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.22em;
  padding: 14px 20px;
  text-align: center;
  outline: none;
  box-shadow:
    0 0 0 1px rgba(56,189,248,0.15) inset,
    0 0 20px rgba(56,189,248,0.1);
  transition:
    border-color 0.3s var(--ease-smooth),
    background   0.3s var(--ease-smooth),
    box-shadow   0.3s var(--ease-smooth);
  caret-color: var(--accent-cyan);
}

#password-input::placeholder {
  color: rgba(240,244,255,0.45);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.26em;
}

#password-input:focus {
  border-color: rgba(56,189,248,0.9);
  background: rgba(4, 5, 15, 0.92);
  box-shadow:
    0 0 0 3px rgba(56,189,248,0.18),
    0 0 28px rgba(56,189,248,0.25);
}

/* Animated underline — replaced with border glow on focus above */
.input-underline { display: none; }

.auth-hint {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: rgba(56,189,248,0.85);
  text-transform: uppercase;
  background: rgba(56,189,248,0.08);
  border: 1px solid rgba(56,189,248,0.35);
  cursor: pointer;
  padding: 10px 20px;
  border-radius: var(--r-sm);
  transition: all var(--t-base);
  text-shadow: 0 0 12px rgba(56,189,248,0.5);
}

.auth-hint:hover {
  color: #fff;
  background: rgba(56,189,248,0.18);
  border-color: rgba(56,189,248,0.65);
  box-shadow: 0 0 20px rgba(56,189,248,0.2);
}

.auth-error {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--accent-rose);
  text-transform: uppercase;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transition: opacity 0.22s ease, transform 0.22s var(--ease-out);
  padding: 8px 14px;
  background: rgba(251,113,133,0.08);
  border: 1px solid rgba(251,113,133,0.2);
  border-radius: var(--r-sm);
  width: 100%;
  justify-content: center;
}

.auth-error.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Shake animation */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%       { transform: translateX(-12px); }
  20%       { transform: translateX(11px); }
  30%       { transform: translateX(-9px); }
  40%       { transform: translateX(8px); }
  50%       { transform: translateX(-5px); }
  60%       { transform: translateX(5px); }
  70%       { transform: translateX(-3px); }
  80%       { transform: translateX(3px); }
}

.input-wrapper.shake {
  animation: shake 0.55s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.input-wrapper.shake #password-input {
  border-color: rgba(251,113,133,0.5);
  background: rgba(251,113,133,0.05);
  box-shadow: 0 0 0 3px rgba(251,113,133,0.1);
}

/* Auth footer */
.auth-footer {
  position: absolute;
  bottom: 24px;
  left: 0; right: 0;
  text-align: center;
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.24em;
  color: var(--text-dim);
  text-transform: uppercase;
  z-index: 2;
  animation: auth-enter 1.4s 0.4s both;
}

/* ════════════════════════════════════════
   DASHBOARD TRANSITIONS
════════════════════════════════════════ */

#dashboard {
  opacity: 0;
  transition: opacity 1s ease;
}

#dashboard.visible {
  opacity: 1;
}

/* ── Tab panel reveal ──────────────────── */
.tab-panel.active {
  animation: tab-reveal 0.4s var(--ease-out) forwards;
}

@keyframes tab-reveal {
  from { opacity: 0; transform: translateY(12px); filter: blur(4px); }
  to   { opacity: 1; transform: translateY(0);    filter: blur(0px); }
}

/* ── Stat card stagger ─────────────────── */
@keyframes card-rise {
  from { opacity: 0; transform: translateY(20px) scale(0.97); filter: blur(6px); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    filter: blur(0px); }
}

.stat-card {
  animation: card-rise 0.5s var(--ease-out) both;
}

.stat-card:nth-child(1)  { animation-delay: 0.04s; }
.stat-card:nth-child(2)  { animation-delay: 0.08s; }
.stat-card:nth-child(3)  { animation-delay: 0.12s; }
.stat-card:nth-child(4)  { animation-delay: 0.16s; }
.stat-card:nth-child(5)  { animation-delay: 0.20s; }
.stat-card:nth-child(6)  { animation-delay: 0.24s; }
.stat-card:nth-child(7)  { animation-delay: 0.28s; }
.stat-card:nth-child(8)  { animation-delay: 0.32s; }
.stat-card:nth-child(9)  { animation-delay: 0.36s; }
.stat-card:nth-child(10) { animation-delay: 0.40s; }
.stat-card:nth-child(11) { animation-delay: 0.44s; }
.stat-card:nth-child(12) { animation-delay: 0.48s; }
.stat-card:nth-child(13) { animation-delay: 0.52s; }
.stat-card:nth-child(14) { animation-delay: 0.56s; }
.stat-card:nth-child(15) { animation-delay: 0.60s; }
.stat-card:nth-child(16) { animation-delay: 0.64s; }

/* ── Loading dots ──────────────────────── */
@keyframes loading-blink {
  0%, 20%   { opacity: 1; }
  50%       { opacity: 0.2; }
  80%, 100% { opacity: 1; }
}

.loading-dots::after {
  content: '...';
  display: inline-block;
  animation: loading-blink 1.4s ease infinite;
}

/* ── Alert item slide-in ───────────────── */
@keyframes alert-slide-in {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

.alert-item {
  animation: alert-slide-in 0.3s var(--ease-out) both;
}

.alert-item:nth-child(1) { animation-delay: 0.05s; }
.alert-item:nth-child(2) { animation-delay: 0.10s; }
.alert-item:nth-child(3) { animation-delay: 0.15s; }
.alert-item:nth-child(4) { animation-delay: 0.20s; }
.alert-item:nth-child(5) { animation-delay: 0.25s; }

/* ── Section label ─────────────────────── */
@keyframes label-in {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

.section-label {
  animation: label-in 0.4s var(--ease-out) both;
}

/* ── Summary pills stagger ─────────────── */
.summary-pill {
  animation: card-rise 0.4s var(--ease-out) both;
}

.summary-pill:nth-child(1) { animation-delay: 0.06s; }
.summary-pill:nth-child(2) { animation-delay: 0.12s; }
.summary-pill:nth-child(3) { animation-delay: 0.18s; }
.summary-pill:nth-child(4) { animation-delay: 0.24s; }
.summary-pill:nth-child(5) { animation-delay: 0.30s; }

/* ── Table row flash ───────────────────── */
@keyframes row-new {
  0%   { background: rgba(56,189,248,0.2); }
  100% { background: transparent; }
}

.data-table tbody tr.flash-row {
  animation: row-new 2s ease-out forwards;
}
