/* ============================================================
   CloudVault — Base CSS
   Reset, CSS Variables, Theme System (Dark/Light), Typography
   ============================================================ */

/* ---------- Google Fonts Import ---------- */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&family=Inter:wght@400;500;600&display=swap');

/* ---------- CSS Reset ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Outfit', 'Inter', -apple-system, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg-primary);
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: -2;
}

.mesh-background {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--bg-primary);
  pointer-events: none;
}

.mesh-background::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: 
    radial-gradient(circle at 30% 30%, var(--mesh-c1) 0%, transparent 40%),
    radial-gradient(circle at 70% 20%, var(--mesh-c2) 0%, transparent 45%),
    radial-gradient(circle at 10% 80%, var(--mesh-c3) 0%, transparent 40%),
    radial-gradient(circle at 80% 90%, var(--mesh-c4) 0%, transparent 45%);
  filter: blur(80px);
  animation: mesh-rotate 40s linear infinite;
  opacity: 0.6;
}

@keyframes mesh-rotate {
  0% { transform: rotate(0deg) scale(1.1); }
  50% { transform: rotate(180deg) scale(1.3); }
  100% { transform: rotate(360deg) scale(1.1); }
}

img, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

table {
  border-collapse: collapse;
  width: 100%;
}

/* ---------- View Transitions ---------- */
::view-transition-group(*),
::view-transition-old(*),
::view-transition-new(*) {
  animation-duration: 0.25s;
  animation-timing-function: cubic-bezier(0.19, 1, 0.22, 1);
}

/* ---------- Theme Variables — Dark (Default) ---------- */
:root,
[data-theme="dark"] {
  /* --- Colors: Core --- */
  --bg-primary: #030305;
  --bg-secondary: #08080c;
  --bg-tertiary: #0c0c14;
  --bg-glass: rgba(10, 10, 20, 0.5);
  --bg-glass-heavy: rgba(15, 15, 25, 0.82);
  --bg-glass-light: rgba(255, 255, 255, 0.03);
  
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-primary-glow: rgba(79, 70, 229, 0.4);
  --color-secondary: #7c3aed;
  --color-accent: #10b981;

  --gradient-primary: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  --gradient-primary-glow: linear-gradient(135deg, rgba(79, 70, 229, 0.6), rgba(124, 58, 237, 0.6));
  
  /* --- Mesh Gradient Palettes --- */
  --mesh-c1: #0f172a;
  --mesh-c2: #1e1b4b;
  --mesh-c3: #312e81;
  --mesh-c4: #1e1b4b;

  /* --- Borders & Glassmorphism --- */
  --border-glass: 1px solid rgba(255, 255, 255, 0.08);
  --border-glass-hover: 1px solid rgba(255, 255, 255, 0.15);
  --blur-glass: blur(20px);
  --blur-glass-sm: blur(8px);
  
  /* --- Typography --- */
  --font-main: 'Outfit', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  --font-size-2xs: 0.625rem;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-md: 1.125rem;
  --font-size-lg: 1.25rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: 2rem;
  --font-size-3xl: 3rem;
  --font-size-4xl: 4rem;

  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-black: 900;

  /* --- Animation --- */
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  
  /* --- Shadow --- */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--color-primary-glow);
  --shadow-glow-lg: 0 0 40px rgba(79, 70, 229, 0.3);

  /* Spacing */
  --space-2xs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  --space-4xl: 96px;

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-collapsed: 80px;
  --topbar-height: 72px;
  --content-max-width: 1400px;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Z-index */
  --z-base: 1;
  --z-sticky: 100;
  --z-overlay: 200;
  --z-modal: 300;
  --z-modal-backdrop: 290;
  --z-toast: 400;
  --z-dropdown: 150;

  /* Text Colors */
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-tertiary: rgba(255, 255, 255, 0.45);

  /* Status Colors */
  --color-success: #10b981;
  --color-success-bg: rgba(16, 185, 129, 0.1);
  --color-warning: #f59e0b;
  --color-warning-bg: rgba(245, 158, 11, 0.1);
  --color-error: #ef4444;
  --color-error-bg: rgba(239, 68, 68, 0.1);
  --color-info: #3b82f6;
  --color-info-bg: rgba(59, 130, 246, 0.1);
  --color-primary-light: rgba(79, 70, 229, 0.1);

  /* Missing variables used elsewhere — dark theme defaults */
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-hover: rgba(255, 255, 255, 0.15);
  --border-color-focus: rgba(79, 70, 229, 0.6);
  --bg-overlay: rgba(0, 0, 0, 0.6);
  --bg-card: rgba(15, 15, 25, 0.6);
  --bg-card-hover: rgba(20, 20, 35, 0.8);
  --bg-input: rgba(255, 255, 255, 0.04);
  --bg-input-focus: rgba(255, 255, 255, 0.08);
  --gradient-hero: linear-gradient(135deg, #030305 0%, #0c0c18 50%, #030305 100%);
  --gradient-card: linear-gradient(135deg, rgba(79, 70, 229, 0.08), rgba(124, 58, 237, 0.08));
  --gradient-shimmer: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.03) 50%, transparent 100%);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.5);
  --scrollbar-bg: transparent;
  --scrollbar-thumb: rgba(255, 255, 255, 0.1);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.2);
  --text-muted: rgba(255, 255, 255, 0.3);
  --text-inverse: #0f172a;
}

/* ---------- Theme Variables — Light ---------- */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-tertiary: #e2e8f0;
  --bg-card: #ffffff;
  --bg-card-hover: #fafafa;
  --bg-glass: rgba(255, 255, 255, 0.7);
  --bg-glass-heavy: rgba(255, 255, 255, 0.85);
  --bg-overlay: rgba(0, 0, 0, 0.4);
  --bg-input: rgba(255, 255, 255, 0.8);
  --bg-input-focus: #ffffff;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --text-muted: #cbd5e1;
  --text-inverse: #f1f5f9;

  --mesh-c1: #f1f5f9;
  --mesh-c2: #e2e8f0;
  --mesh-c3: #cbd5e1;
  --mesh-c4: #f1f5f9;

  --color-primary: #4f46e5;
  --color-secondary: #7c3aed;
  --color-primary-light: rgba(79, 70, 229, 0.08);

  --border-glass: 1px solid rgba(0, 0, 0, 0.06);
  --border-glass-hover: 1px solid rgba(0, 0, 0, 0.12);

  --gradient-primary: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  --gradient-hero: linear-gradient(135deg, #f5f5f7 0%, #e8e8f0 50%, #f5f5f7 100%);
  --gradient-card: linear-gradient(135deg, rgba(59, 130, 246, 0.05), rgba(139, 92, 246, 0.05));
  --gradient-shimmer: linear-gradient(90deg, transparent 0%, rgba(0,0,0,0.03) 50%, transparent 100%);

  --border-color: rgba(0, 0, 0, 0.08);
  --border-color-hover: rgba(0, 0, 0, 0.15);
  --border-color-focus: rgba(79, 70, 229, 0.5);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.1);
  --shadow-glow-lg: 0 0 40px rgba(79, 70, 229, 0.15);

  --scrollbar-bg: transparent;
  --scrollbar-thumb: rgba(0, 0, 0, 0.15);
  --scrollbar-thumb-hover: rgba(0, 0, 0, 0.25);
}

/* ---------- Body base ---------- */
body {
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: background var(--transition), color var(--transition);
}

/* ---------- Custom Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--scrollbar-bg);
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* ---------- Selection ---------- */
::selection {
  background: rgba(59, 130, 246, 0.3);
  color: var(--text-primary);
}

/* ---------- Focus Styles ---------- */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ---------- Typography Helpers ---------- */
.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-md { font-size: var(--font-size-md); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }
.text-3xl { font-size: var(--font-size-3xl); }
.text-4xl { font-size: var(--font-size-4xl); }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-tertiary); }

.font-light { font-weight: var(--font-weight-light); }
.font-normal { font-weight: var(--font-weight-normal); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }
.font-black { font-weight: var(--font-weight-black); }

/* ---------- Skeleton Loading ---------- */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: var(--bg-glass);
  background-image: var(--gradient-shimmer);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ---------- Utility : Hidden / SR-Only ---------- */
.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;
}

.hidden {
  display: none !important;
}
