@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
  color-scheme: dark;
  --aurora-1: #7c5cff;
  --aurora-2: #22d3ee;
  --aurora-3: #ff5cd7;
}

html, body {
  background: #070815;
  color: #eef0f7;
  font-family: var(--font-geist-sans), ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* === Aurora background === */
body::before {
  content: "";
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 80vh;
  z-index: -1;
  background:
    radial-gradient(closest-side at 25% 30%, rgba(124, 92, 255, 0.35), transparent 70%),
    radial-gradient(closest-side at 75% 20%, rgba(34, 211, 238, 0.25), transparent 65%),
    radial-gradient(closest-side at 50% 80%, rgba(255, 92, 215, 0.18), transparent 70%);
  filter: blur(60px) saturate(140%);
  animation: aurora-shift 22s ease-in-out infinite;
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse at 50% 0%, rgba(0,0,0,1), rgba(0,0,0,0) 70%);
}

@keyframes aurora-shift {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  33% { transform: translate3d(4%, -3%, 0) rotate(6deg); }
  66% { transform: translate3d(-3%, 2%, 0) rotate(-4deg); }
}

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
}

/* === Components === */
@layer components {
  /* Card với subtle gradient border qua mask */
  .card {
    @apply relative rounded-xl bg-panel/80 backdrop-blur-md;
    background-image:
      linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0)),
      linear-gradient(180deg, rgb(12 14 26 / 0.85), rgb(12 14 26 / 0.6));
    border: 1px solid rgba(255,255,255,0.06);
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.04),
      0 8px 32px -12px rgba(0,0,0,0.6);
  }
  .card-glow {
    @apply card;
    position: relative;
  }
  .card-glow::before {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(124,92,255,0.5), rgba(34,211,238,0.3) 50%, transparent 80%);
    -webkit-mask:
      linear-gradient(#fff 0 0) content-box,
      linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    pointer-events: none;
    opacity: 0.6;
  }

  /* Buttons */
  .btn {
    @apply inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium
           border border-border bg-panel/60 backdrop-blur
           text-ink/90 hover:text-ink hover:border-borderHi
           hover:bg-panel transition-all duration-150
           active:scale-[0.98];
  }
  .btn-primary {
    @apply text-white border-transparent;
    background-image: linear-gradient(135deg, #7c5cff 0%, #6b4cff 50%, #4f87ff 100%);
    box-shadow:
      0 0 0 1px rgba(124,92,255,0.4),
      0 8px 24px -8px rgba(124,92,255,0.5),
      inset 0 1px 0 rgba(255,255,255,0.18);
  }
  .btn-primary:hover {
    box-shadow:
      0 0 0 1px rgba(124,92,255,0.6),
      0 12px 28px -8px rgba(124,92,255,0.6),
      inset 0 1px 0 rgba(255,255,255,0.22);
    filter: brightness(1.08);
  }
  .btn-danger {
    @apply text-white border-transparent;
    background-image: linear-gradient(135deg, #fb7185 0%, #e11d48 100%);
    box-shadow: 0 8px 24px -8px rgba(251,113,133,0.4), inset 0 1px 0 rgba(255,255,255,0.15);
  }
  .btn-ghost {
    @apply inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm
           text-muted hover:text-ink hover:bg-white/5 transition-all;
    border: none;
    background: transparent;
  }

  /* Inputs */
  .input {
    @apply w-full bg-panel/60 backdrop-blur border border-border rounded-lg px-3 py-2 text-sm
           text-ink placeholder:text-muted
           focus:outline-none focus:border-accent focus:ring-2 focus:ring-accent/30
           transition-all duration-150;
  }
  .input:disabled, .input[readonly] {
    @apply opacity-70 cursor-not-allowed;
  }
  .label {
    @apply text-[11px] uppercase tracking-wider text-muted mb-1.5 block font-medium;
  }

  /* Chips */
  .chip {
    @apply inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-medium
           border border-border bg-panel/60 text-ink/80;
  }
  .chip-ok {
    @apply chip text-ok;
    background: rgba(52,211,153,0.08);
    border-color: rgba(52,211,153,0.25);
  }
  .chip-bad {
    @apply chip text-bad;
    background: rgba(251,113,133,0.08);
    border-color: rgba(251,113,133,0.25);
  }
  .chip-warn {
    @apply chip text-warn;
    background: rgba(251,191,36,0.08);
    border-color: rgba(251,191,36,0.3);
  }
  .chip-accent {
    @apply chip;
    color: #b8a5ff;
    background: rgba(124,92,255,0.08);
    border-color: rgba(124,92,255,0.3);
  }

  /* Tables */
  .table { @apply w-full text-sm; }
  .table th {
    @apply text-left text-[11px] uppercase tracking-wider font-semibold text-muted py-2.5 px-3
           border-b border-border;
  }
  .table td {
    @apply py-2.5 px-3 border-b border-border/60;
  }
  .table tbody tr {
    @apply transition-colors;
  }
  .table tbody tr:hover {
    background: linear-gradient(90deg, rgba(124,92,255,0.04), rgba(34,211,238,0.02));
  }
  .table tbody tr:last-child td { @apply border-b-0; }

  /* Sidebar nav */
  .nav-item {
    @apply relative px-3 py-2 rounded-lg text-sm text-muted
           hover:text-ink hover:bg-white/[0.04] transition-all duration-150;
  }
  .nav-item-active {
    @apply nav-item text-ink;
    background: linear-gradient(90deg, rgba(124,92,255,0.15), rgba(124,92,255,0.04) 70%, transparent);
  }
  .nav-item-active::before {
    content: "";
    position: absolute;
    left: 0; top: 6px; bottom: 6px;
    width: 2px;
    background: linear-gradient(180deg, #7c5cff, #22d3ee);
    border-radius: 2px;
  }

  /* Status dot — only for actual semantic state */
  .dot { @apply inline-block w-1.5 h-1.5 rounded-full; }
  .dot-ok { @apply dot bg-ok; box-shadow: 0 0 8px rgba(52,211,153,0.6); }
  .dot-bad { @apply dot bg-bad; box-shadow: 0 0 8px rgba(251,113,133,0.5); }
  .dot-warn { @apply dot bg-warn; box-shadow: 0 0 8px rgba(251,191,36,0.5); }

  /* Heading utilities */
  .h-gradient {
    background: linear-gradient(135deg, #ffffff 0%, #b8a5ff 50%, #7dd3fc 100%);
    -webkit-background-clip: text;
            background-clip: text;
    color: transparent;
  }

  /* Skeleton shimmer */
  .skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.6s linear infinite;
    @apply rounded;
  }
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(124,92,255,0.4); background-clip: padding-box; }
