@import "tailwindcss";
@plugin "tailwindcss-animate";
@plugin "@tailwindcss/typography";

@custom-variant dark (&:is(.dark *));

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --font-sans: var(--font-geist-sans);
  --font-mono: var(--font-geist-mono);
  
  --color-sidebar-ring: var(--sidebar-ring);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
  --color-sidebar-primary: var(--sidebar-primary);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar: var(--sidebar);
  
  --color-chart-5: var(--chart-5);
  --color-chart-4: var(--chart-4);
  --color-chart-3: var(--chart-3);
  --color-chart-2: var(--chart-2);
  --color-chart-1: var(--chart-1);
  
  --color-ring: var(--ring);
  --color-input: var(--input);
  --color-border: var(--border);
  --color-destructive: var(--destructive);
  --color-accent-foreground: var(--accent-foreground);
  --color-accent: var(--accent);
  --color-muted-foreground: var(--muted-foreground);
  --color-muted: var(--muted);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-secondary: var(--secondary);
  --color-primary-foreground: var(--primary-foreground);
  --color-primary: var(--primary);
  --color-popover-foreground: var(--popover-foreground);
  --color-popover: var(--popover);
  --color-card-foreground: var(--card-foreground);
  --color-card: var(--card);
  
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --radius-2xl: calc(var(--radius) + 8px);
  --radius-3xl: calc(var(--radius) + 12px);
  --radius-4xl: calc(var(--radius) + 16px);
}

:root {
  --radius: 0.75rem;
  /* Light Mode - Ultra clean, subtle cool tints */
  --background: oklch(0.99 0.01 240);
  --foreground: oklch(0.15 0.05 240);
  
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.15 0.05 240);
  
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.15 0.05 240);
  
  /* Primary - Vibrant Modern Cobalt/Royal Blue */
  --primary: oklch(0.55 0.22 255);
  --primary-foreground: oklch(0.98 0.01 255);
  
  /* Secondary - Soft slate-blue */
  --secondary: oklch(0.96 0.03 240);
  --secondary-foreground: oklch(0.28 0.08 255);
  
  --muted: oklch(0.95 0.02 240);
  --muted-foreground: oklch(0.45 0.04 240);
  
  --accent: oklch(0.95 0.04 250);
  --accent-foreground: oklch(0.2 0.08 255);
  
  --destructive: oklch(0.6 0.25 25);
  --destructive-foreground: oklch(0.98 0 0);
  
  --border: oklch(0.9 0.02 240);
  --input: oklch(0.9 0.02 240);
  --ring: oklch(0.55 0.22 255);
  
  --chart-1: oklch(0.55 0.22 255);
  --chart-2: oklch(0.65 0.16 220);
  --chart-3: oklch(0.50 0.18 280);
  --chart-4: oklch(0.70 0.14 195);
  --chart-5: oklch(0.60 0.18 310);

  --sidebar: oklch(0.98 0.01 240);
  --sidebar-foreground: oklch(0.2 0.04 240);
  --sidebar-primary: oklch(0.55 0.22 255);
  --sidebar-primary-foreground: oklch(0.98 0.01 255);
  --sidebar-accent: oklch(0.95 0.03 250);
  --sidebar-accent-foreground: oklch(0.2 0.08 255);
  --sidebar-border: oklch(0.9 0.02 240);
  --sidebar-ring: oklch(0.55 0.22 255);
}

.dark {
  /* Dark Mode - Deep, rich blue-black */
  --background: oklch(0.15 0.02 240);
  --foreground: oklch(0.98 0.01 240);
  
  /* Slightly elevated surfaces for cards */
  --card: oklch(0.18 0.03 240);
  --card-foreground: oklch(0.98 0.01 240);
  
  --popover: oklch(0.18 0.03 240);
  --popover-foreground: oklch(0.98 0.01 240);
  
  /* Primary - Bright, glowing Tech Sapphire Blue */
  --primary: oklch(0.65 0.22 255);
  --primary-foreground: oklch(0.12 0.04 255);
  
  --secondary: oklch(0.22 0.04 240);
  --secondary-foreground: oklch(0.95 0.02 240);
  
  --muted: oklch(0.2 0.03 240);
  --muted-foreground: oklch(0.65 0.04 240);
  
  --accent: oklch(0.24 0.06 250);
  --accent-foreground: oklch(0.98 0.01 240);
  
  --destructive: oklch(0.5 0.25 25);
  
  --border: oklch(0.25 0.04 240);
  --input: oklch(0.25 0.04 240);
  --ring: oklch(0.65 0.22 255);

  --chart-1: oklch(0.65 0.22 255);
  --chart-2: oklch(0.75 0.16 220);
  --chart-3: oklch(0.60 0.18 280);
  --chart-4: oklch(0.80 0.14 195);
  --chart-5: oklch(0.70 0.18 310);

  --sidebar: oklch(0.16 0.02 240);
  --sidebar-foreground: oklch(0.95 0.01 240);
  --sidebar-primary: oklch(0.65 0.22 255);
  --sidebar-primary-foreground: oklch(0.12 0.04 255);
  --sidebar-accent: oklch(0.22 0.05 250);
  --sidebar-accent-foreground: oklch(0.98 0.01 240);
  --sidebar-border: oklch(0.25 0.04 240);
  --sidebar-ring: oklch(0.65 0.22 255);
}

@layer base {
  * {
    @apply border-border outline-ring/50;
  }
  body {
    @apply bg-background text-foreground tracking-tight scroll-smooth;
  }
}

/* Custom Utilities for Glassmorphism & Micro-animations */
@layer utilities {
  .glass {
    @apply bg-white/70 dark:bg-slate-900/70 backdrop-blur-xl border border-white/20 dark:border-white/10 shadow-xl;
  }
  
  .glass-panel {
    @apply bg-white/50 dark:bg-slate-900/50 backdrop-blur-md border border-slate-200/50 dark:border-slate-800/50;
  }
  
  .text-gradient {
    @apply bg-clip-text text-transparent bg-gradient-to-r from-blue-600 via-indigo-600 to-cyan-500 dark:from-blue-400 dark:via-indigo-300 dark:to-cyan-400;
  }
  
  .hover-lift {
    @apply transition-all duration-300 ease-out hover:-translate-y-1 hover:shadow-lg hover:shadow-blue-500/20;
  }
  
  .animate-float {
    animation: float 6s ease-in-out infinite;
  }

  .animate-pulse-glow {
    animation: pulse-glow 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  }

  @keyframes float {
    0% {
      transform: translateY(0px);
    }
    50% {
      transform: translateY(-20px);
    }
    100% {
      transform: translateY(0px);
    }
  }

  @keyframes pulse-glow {
    0%, 100% {
      opacity: 0.8;
      transform: scale(1);
    }
    50% {
      opacity: 1;
      transform: scale(1.05);
    }
  }

  /* ---- Premium landing utilities ---- */

  /* Subtle dotted/grid background overlay */
  .bg-grid {
    background-image:
      linear-gradient(to right, color-mix(in oklch, var(--foreground) 6%, transparent) 1px, transparent 1px),
      linear-gradient(to bottom, color-mix(in oklch, var(--foreground) 6%, transparent) 1px, transparent 1px);
    background-size: 56px 56px;
    -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black 40%, transparent 100%);
    mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black 40%, transparent 100%);
  }

  /* Animated multi-color gradient text */
  .text-gradient-animate {
    background-image: linear-gradient(110deg, var(--primary), oklch(0.7 0.18 230), oklch(0.6 0.22 280), var(--primary));
    background-size: 250% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: gradient-pan 6s ease infinite;
  }

  /* Gradient border wrapper (use as parent, inner gets bg) */
  .glow-border {
    position: relative;
    isolation: isolate;
  }
  .glow-border::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, color-mix(in oklch, var(--primary) 60%, transparent), transparent 40%, transparent 60%, color-mix(in oklch, var(--primary) 40%, transparent));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: -1;
  }

  /* Soft shimmer sweep on hover */
  .shimmer {
    position: relative;
    overflow: hidden;
  }
  .shimmer::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 30%, color-mix(in oklch, white 25%, transparent) 50%, transparent 70%);
    transform: translateX(-120%);
    transition: transform 0.8s ease;
  }
  .shimmer:hover::after {
    transform: translateX(120%);
  }

  @keyframes gradient-pan {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
  }
}

/* ============================================================
 * Translation safety + responsive baseline
 * ============================================================ */

/* Browser translators (Google Translate) inject `<font>` tags inside text
 * nodes which breaks React reconciliation. The `.notranslate` class is the
 * standard way to opt content out, and we also reset the inline `<font>`
 * styles in case a translator still touches the page so the layout doesn't
 * collapse. */
.notranslate,
[translate="no"] {
    /* Belt-and-suspenders: signal to translators we manage this content */
}

font {
    font: inherit;
    color: inherit;
}

/* Prevent horizontal scroll on small screens caused by overflowing children
 * (e.g. long unbroken strings, wide tables). `overflow-x: hidden` is too
 * aggressive globally; use `overflow-wrap` to soft-break long words instead. */
html,
body {
    overflow-x: hidden;
    overflow-wrap: anywhere;
    -webkit-text-size-adjust: 100%; /* iOS Safari zoom-on-rotate fix */
}

/* Avoid iOS auto-zoom on focus when input font-size < 16px */
@media (max-width: 640px) {
    input,
    textarea,
    select {
        font-size: 16px;
    }
}

/* Make tables scrollable inside their container instead of overflowing */
.responsive-table-wrapper {
    @apply w-full overflow-x-auto -mx-2 px-2 sm:mx-0 sm:px-0;
}

/* Better tap targets on mobile */
@media (max-width: 640px) {
    button,
    a[role="button"],
    [role="tab"] {
        min-height: 36px;
    }
}

/* Style the existing styled-scrollbar utility for consistency */
.styled-scrollbar {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.styled-scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.styled-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.styled-scrollbar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}
.styled-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--muted-foreground);
}

/* ============================================================
 * Mobile-friendly defaults for common patterns
 * ============================================================ */

/* Prevent dialogs from being wider than viewport on small screens.
 * Radix DialogContent applies fixed width — these rules ensure it
 * never exceeds the available width. */
[data-slot="dialog-content"] {
    max-width: calc(100vw - 1.5rem) !important;
    max-height: calc(100vh - 2rem) !important;
}

/* On very small screens, allow dialog to use almost full viewport */
@media (max-width: 480px) {
    [data-slot="dialog-content"] {
        max-width: calc(100vw - 1rem) !important;
        padding: 1rem !important;
    }
}

/* Cards should never overflow their parent on mobile */
@media (max-width: 640px) {
    [data-slot="card"] {
        max-width: 100%;
    }
}

/* File inputs render inconsistently on mobile — make them shrinkable */
input[type="file"] {
    max-width: 100%;
}

/* Long unbreakable strings (URLs, JIDs, hashes) should wrap inside cards */
.break-anywhere,
.card-content {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Tables in dashboards should scroll horizontally on mobile, not overflow page */
.dashboard-table-wrapper {
    @apply w-full overflow-x-auto -mx-3 px-3 sm:mx-0 sm:px-0;
}

/* Code/JID/URL spans should always be selectable & wrappable */
code,
kbd,
.font-mono {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Hide scrollbar but keep scroll functionality (for horizontal tab filters) */
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
