/* CSS Variables for theming */
:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-light: rgba(16, 185, 129, 0.1);
  --coral: #f97316;
  --coral-hover: #ea580c;
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(255, 255, 255, 0.3);
  --shadow-color: rgba(0, 0, 0, 0.1);
  --scrollbar-track: #f1f5f9;
  --scrollbar-thumb: #cbd5e1;
}

.dark {
  --bg-primary: #0c0f14;
  --bg-secondary: #151921;
  --bg-tertiary: #1e2430;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: #2d3748;
  --glass-bg: rgba(21, 25, 33, 0.85);
  --glass-border: rgba(255, 255, 255, 0.08);
  --shadow-color: rgba(0, 0, 0, 0.4);
  --scrollbar-track: #151921;
  --scrollbar-thumb: #374151;
}

/* Base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 5px;
  border: 2px solid var(--scrollbar-track);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* Glassmorphism */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
}

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  transition: all 0.3s ease;
  margin: 5px;
}

.glass-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px var(--shadow-color);
}

/* Navbar styles */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 0.5rem 0;
  transition: all 0.3s ease;
}

.navbar.scrolled {
  padding: 0.25rem 0;
  box-shadow: 0 4px 30px var(--shadow-color);
}

/* Logo gradient */
.logo-gradient {
  background: linear-gradient(135deg, var(--accent) 0%, var(--coral) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #0d9488 100%);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  font-weight: 600;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(16, 185, 129, 0.3);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  font-weight: 600;
  transition: all 0.3s ease;
  border: 2px solid var(--border-color);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-coral {
  background: linear-gradient(135deg, var(--coral) 0%, #dc2626 100%);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  font-weight: 600;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
}

.btn-coral:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(249, 115, 22, 0.3);
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: auto;
  max-width: 90vw;
}

.toast {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 1rem 1.5rem;
  border-radius: 12px;
  box-shadow: 0 10px 40px var(--shadow-color);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideUp 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  border-left: 4px solid var(--accent);
  white-space: nowrap;
}

.toast.success {
  border-left-color: var(--accent);
}

.toast.error {
  border-left-color: #ef4444;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* Color blocks */
.color-block {
  position: relative;
  cursor: pointer;
  transition: all 0.3s ease;
  overflow: hidden;
}

.color-block:hover {
  transform: scale(1.02);
}

.color-block::after {
  content: 'Click to copy';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 0.75rem;
  text-align: center;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.color-block:hover::after {
  transform: translateY(0);
}

/* Lock button */
.lock-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  opacity: 0;
}

.color-block:hover .lock-btn {
  opacity: 1;
}

.lock-btn:hover {
  background: rgba(0, 0, 0, 0.5);
  transform: scale(1.1);
}

.lock-btn.locked {
  opacity: 1;
  background: var(--accent);
}

/* Refresh button */
.refresh-btn {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  opacity: 0;
}

.color-block:hover .refresh-btn {
  opacity: 1;
}

.refresh-btn:hover {
  background: rgba(0, 0, 0, 0.5);
  transform: rotate(180deg);
}

/* Gradient preview */
.gradient-preview {
  border-radius: 16px;
  min-height: 200px;
  transition: all 0.3s ease;
}

/* Input styles */
.input-field {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 1rem;
  transition: all 0.3s ease;
}

.input-field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* Range slider */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  outline: none;
  transition: all 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 10px var(--accent);
}

/* Mobile menu */
.mobile-menu {
  /* Base styling handled by Tailwind in JS, but adding fallback/transition support */
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  /* Force hardware acceleration */
  will-change: transform;
}

/* Hamburger */
.hamburger {
  width: 28px;
  height: 20px;
  position: relative;
  cursor: pointer;
  display: none;
}

.hamburger span {
  position: absolute;
  width: 100%;
  height: 3px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.hamburger span:nth-child(1) {
  top: 0;
}

.hamburger span:nth-child(2) {
  top: 50%;
  transform: translateY(-50%);
}

.hamburger span:nth-child(3) {
  bottom: 0;
}

.hamburger.active span:nth-child(1) {
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
}

.hamburger.active span:nth-child(3) {
  bottom: 50%;
  transform: translateY(50%) rotate(-45deg);
}

/* Hero patterns */
.hero-pattern {
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(circle at 20% 50%, rgba(16, 185, 129, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(249, 115, 22, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 40% 80%, rgba(16, 185, 129, 0.08) 0%, transparent 40%);
  pointer-events: none;
}

/* Grid pattern */
.grid-pattern {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(var(--border-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-color) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: 0.3;
  pointer-events: none;
}

/* Animations */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
  }
  50% {
    box-shadow: 0 0 40px rgba(16, 185, 129, 0.5);
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.shimmer {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

/* ==========================================
   RESPONSIVE STYLES (Mobile First)
   ========================================== */

@media (max-width: 768px) {
  /* Layout Adjustments */
  body {
    font-size: 15px;
  }

  /* Navbar Mobile */
  .navbar {
    padding: 0.25rem 0;
  }

  .hamburger {
    display: block;
    z-index: 1001;
  }
  
  .nav-links {
    display: none;
  }

  /* Buttons Mobile */
  .btn-primary, .btn-secondary, .btn-coral {
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
    width: 100%;
    justify-content: center;
  }

  .btn-size {
    width: 12%;
  }

  /* Cards Mobile */
  .glass-card {
    padding: 1rem;
    margin: 0.5rem 0;
    border-radius: 12px;
  }

  .glass-card:hover {
    transform: none; /* Disable hover lift on mobile for better scroll performance */
  }

  /* Hero Section Mobile */
  .hero-pattern, .grid-pattern {
    background-size: 100% 100%, 100% 100%; /* Simplify gradients */
    opacity: 0.8;
  }

  /* Toast Mobile */
  .toast-container {
    bottom: 1rem;
    width: 95%;
    max-width: unset;
  }

  .toast {
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    width: 100%;
    justify-content: center;
  }

  /* Color Blocks Mobile */
  .color-block::after {
    content: 'Tap to copy';
    font-size: 0.65rem;
    padding: 0.25rem;
  }

  /* Inputs Mobile */
  .input-field {
    font-size: 16px; /* Prevents iOS zoom on focus */
    padding: 0.6rem 0.8rem;
  }

  /* Gradient Preview Mobile */
  .gradient-preview {
    min-height: 180px;
    border-radius: 12px;
  }

  /* Mobile Menu Overlay (Tailwind handles most, these are backups) */
  .mobile-menu {
    padding-top: 5rem; /* Space for navbar */
    padding-bottom: 2rem;
  }
}

@media (max-width: 480px) {
  /* Extra small devices */
  h1 {
    font-size: 1.75rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }

  .btn-primary, .btn-secondary {
    font-size: 0.85rem;
  }
}

/* Focus visible for accessibility */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Selection */
::selection {
  background: var(--accent);
  color: white;
}

/* Print styles */
@media print {
  .navbar,
  .mobile-menu,
  .toast-container {
    display: none !important;
  }
}

/* ==========================================
   BACK TO TOP BUTTON STYLES
   ========================================== */

.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #0d9488 100%);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
  z-index: 9998;
}

.back-to-top:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.5);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

@media (max-width: 768px) {
  .back-to-top {
    bottom: 1.5rem;
    right: 1.5rem;
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }
}
