/* ============================================
   EcoMind AI Tools — Custom Design System
   Extends Tailwind CSS
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-hero: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
  --gradient-accent: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-success: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
  --glow-purple: 0 0 30px rgba(102, 126, 234, 0.4);
  --glow-pink: 0 0 30px rgba(240, 147, 251, 0.4);
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.15);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  --card-radius: 16px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== BACKGROUND PHOTO (Light mode) ===== */
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  /* Semi-transparent white overlay ON TOP of the background photo */
  background:
    linear-gradient(rgba(235, 240, 255, 0.80), rgba(235, 240, 255, 0.80)),
    url('../images/bg.png') center / cover fixed;
  color: #1e293b;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}

/* Light mode has no pseudo-elements now — background is on body directly */
body::before,
body::after {
  display: none;
}

@keyframes bgFloat {
  0% {
    opacity: 0.90;
  }

  50% {
    opacity: 0.85;
  }

  100% {
    opacity: 0.90;
  }
}

/* ===== DARK MODE BACKGROUND ===== */
.dark body,
body.dark {
  /* Glowing orbs + dark overlay ON TOP of the background photo */
  background:
    radial-gradient(ellipse 70% 50% at 15% 15%, rgba(99, 102, 241, 0.35) 0%, transparent 55%),
    radial-gradient(ellipse 55% 40% at 85% 10%, rgba(139, 92, 246, 0.28) 0%, transparent 50%),
    radial-gradient(ellipse 60% 45% at 60% 88%, rgba(236, 72, 153, 0.22) 0%, transparent 55%),
    radial-gradient(ellipse 45% 35% at 5% 78%, rgba(16, 185, 129, 0.14) 0%, transparent 50%),
    radial-gradient(ellipse 50% 40% at 95% 60%, rgba(59, 130, 246, 0.20) 0%, transparent 50%),
    linear-gradient(rgba(6, 13, 31, 0.68), rgba(6, 13, 31, 0.68)),
    url('../images/bg.png') center / cover fixed;
  color: #e2e8f0;
}

/* Dark mode has no pseudo-elements either */
.dark body::before,
.dark body::after,
body.dark::before,
body.dark::after {
  display: none;
}

@keyframes darkBgFloat {
  0% {
    opacity: 1;
    filter: hue-rotate(0deg);
  }

  50% {
    opacity: 0.90;
    filter: hue-rotate(15deg);
  }

  100% {
    opacity: 1;
    filter: hue-rotate(-8deg);
  }
}

.dark .glass-card {
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(99, 102, 241, 0.15);
}

.dark .tool-card {
  background: rgba(15, 23, 42, 0.7);
  border-color: rgba(99, 102, 241, 0.1);
}

.dark .tool-card:hover {
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 20px 60px rgba(99, 102, 241, 0.15);
}

.dark .category-card {
  background: rgba(15, 23, 42, 0.8);
  border-color: rgba(255, 255, 255, 0.06);
}

.dark .category-card:hover {
  border-color: rgba(99, 102, 241, 0.3);
}

.dark .nav-glass {
  background: rgba(11, 17, 32, 0.85);
  border-bottom-color: rgba(99, 102, 241, 0.1);
}

.dark input,
.dark textarea,
.dark select {
  background: rgba(15, 23, 42, 0.8) !important;
  border-color: rgba(99, 102, 241, 0.2) !important;
  color: #e2e8f0 !important;
}

.dark .footer-section {
  background: #070d1a;
  border-top-color: rgba(99, 102, 241, 0.1);
}

.dark .ad-placeholder {
  background: rgba(15, 23, 42, 0.5);
  border-color: rgba(99, 102, 241, 0.1);
}

.dark .cta-section {
  background: rgba(15, 23, 42, 0.6);
}

.dark .search-container input {
  background: rgba(15, 23, 42, 0.8) !important;
}

/* ---------- Animated Gradient Background ---------- */
.hero-gradient {
  background: linear-gradient(-45deg, #0f0c29, #302b63, #24243e, #1a1a2e, #16213e, #0f3460);
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

/* ---------- Glassmorphism ---------- */
.glass-card {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--card-radius);
  box-shadow: var(--glass-shadow);
  transition: var(--transition-smooth);
}

.glass-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

/* ---------- Nav Glass ---------- */
.nav-glass {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  transition: var(--transition-smooth);
}

.nav-glass.scrolled {
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.08);
}

/* ---------- Tool Cards ---------- */
.tool-card {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--card-radius);
  padding: 1.5rem;
  transition: var(--transition-smooth);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-primary);
  transform: scaleX(0);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: left;
}

.tool-card:hover::before {
  transform: scaleX(1);
}

.tool-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 60px rgba(102, 126, 234, 0.12);
  border-color: rgba(102, 126, 234, 0.2);
}

.tool-card .tool-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1rem;
  transition: var(--transition-smooth);
}

.tool-card:hover .tool-icon {
  transform: scale(1.1) rotate(-3deg);
}

/* ---------- Category Cards ---------- */
.category-card {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 20px;
  padding: 2rem;
  text-align: center;
  transition: var(--transition-smooth);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.category-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 20px;
  padding: 2px;
  background: var(--gradient-primary);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: xor;
  -webkit-mask-composite: xor;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.category-card:hover::after {
  opacity: 1;
}

.category-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 25px 60px rgba(102, 126, 234, 0.15);
}

.category-card .category-icon {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1.25rem;
  transition: var(--transition-smooth);
}

.category-card:hover .category-icon {
  transform: scale(1.15) rotate(-5deg);
}

/* ---------- Featured / Glow Cards ---------- */
.glow-card {
  position: relative;
  background: #fff;
  border-radius: var(--card-radius);
  padding: 2rem;
  transition: var(--transition-smooth);
  overflow: hidden;
}

.glow-card::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: calc(var(--card-radius) + 2px);
  background: linear-gradient(135deg, #667eea, #f093fb, #f5576c, #667eea);
  background-size: 300% 300%;
  animation: glowRotate 4s linear infinite;
  z-index: -1;
}

.glow-card::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: calc(var(--card-radius) - 2px);
  background: #fff;
  z-index: -1;
}

.dark .glow-card::after {
  background: #0f172a;
}

@keyframes glowRotate {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

.glow-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--glow-purple);
}

/* ---------- Buttons ---------- */
.btn-primary {
  background: var(--gradient-primary);
  color: white;
  border: none;
  padding: 12px 28px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
  opacity: 0;
  transition: opacity 0.3s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(102, 126, 234, 0.35);
}

.btn-primary:hover::before {
  opacity: 1;
}

.btn-primary span {
  position: relative;
  z-index: 1;
}

.btn-secondary {
  background: transparent;
  color: #667eea;
  border: 2px solid #667eea;
  padding: 10px 24px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-secondary:hover {
  background: #667eea;
  color: white;
  transform: translateY(-2px);
}

/* ---------- Search ---------- */
.search-container {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
}

.search-container input {
  width: 100%;
  padding: 16px 20px 16px 52px;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  color: white;
  font-size: 1rem;
  outline: none;
  transition: var(--transition-smooth);
}

.search-container input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.search-container input:focus {
  border-color: rgba(102, 126, 234, 0.6);
  box-shadow: 0 0 30px rgba(102, 126, 234, 0.2);
}

.search-container .search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.5);
}

/* ---------- Search Results Dropdown ---------- */
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  max-height: 400px;
  overflow-y: auto;
  z-index: 100;
  display: none;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.dark .search-results {
  background: #1e293b;
  border-color: rgba(99, 102, 241, 0.15);
}

.search-results.active {
  display: block;
  animation: slideDown 0.2s ease;
}

.search-result-item {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  color: inherit;
}

.search-result-item:hover {
  background: rgba(102, 126, 234, 0.08);
}

.search-result-item .result-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

/* ---------- Scroll Animations ---------- */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal-left {
  opacity: 0;
  transform: translateX(-40px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal-left.visible {
  opacity: 1;
  transform: translateX(0);
}

.reveal-right {
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal-right.visible {
  opacity: 1;
  transform: translateX(0);
}

.reveal-scale {
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal-scale.visible {
  opacity: 1;
  transform: scale(1);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

/* ---------- Loading Spinner ---------- */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(102, 126, 234, 0.2);
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 2rem auto;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--card-radius);
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.dark .loading-overlay {
  background: rgba(11, 17, 32, 0.85);
}

/* ---------- Tool Page Specific ---------- */
.tool-input-area {
  background: #fff;
  border: 2px dashed rgba(0, 0, 0, 0.1);
  border-radius: var(--card-radius);
  padding: 2rem;
  transition: var(--transition-smooth);
  position: relative;
}

.tool-input-area:hover,
.tool-input-area:focus-within {
  border-color: rgba(102, 126, 234, 0.4);
  box-shadow: 0 0 30px rgba(102, 126, 234, 0.08);
}

.dark .tool-input-area {
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(99, 102, 241, 0.15);
}

.tool-output-area {
  background: #f1f5f9;
  border-radius: var(--card-radius);
  padding: 1.5rem;
  min-height: 120px;
  position: relative;
  transition: var(--transition-smooth);
}

.dark .tool-output-area {
  background: rgba(15, 23, 42, 0.6);
}

/* File Drop Zone */
.drop-zone {
  border: 2px dashed rgba(102, 126, 234, 0.3);
  border-radius: var(--card-radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: #667eea;
  background: rgba(102, 126, 234, 0.04);
}

.drop-zone.dragover {
  transform: scale(1.02);
}

/* ---------- Ad Placeholders ---------- */
.ad-placeholder {
  background: #f1f5f9;
  border: 1px dashed rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  color: #94a3b8;
  font-size: 0.8rem;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.ad-placeholder.ad-banner {
  min-height: 90px;
}

.ad-placeholder.ad-sidebar {
  min-height: 250px;
}

.ad-placeholder.ad-inline {
  min-height: 100px;
  margin: 1.5rem 0;
}

/* ---------- Footer ---------- */
.footer-section {
  background: #0f172a;
  color: #94a3b8;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.footer-section a {
  color: #94a3b8;
  text-decoration: none;
  transition: color 0.2s;
}

.footer-section a:hover {
  color: #667eea;
}

/* ---------- CTA Section ---------- */
.cta-section {
  background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
  border-radius: 24px;
  transition: var(--transition-smooth);
}

/* ---------- Tooltip ---------- */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(5px);
  background: #1e293b;
  color: white;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
}

.tooltip:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Dark Mode Toggle ---------- */
.dark-toggle {
  width: 48px;
  height: 26px;
  background: #e2e8f0;
  border-radius: 13px;
  cursor: pointer;
  position: relative;
  transition: background 0.3s;
  border: none;
  padding: 0;
}

.dark-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.dark .dark-toggle {
  background: #667eea;
}

.dark .dark-toggle::after {
  transform: translateX(22px);
}

/* ---------- Bookmark Star ---------- */
.bookmark-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  transition: var(--transition-smooth);
  padding: 4px;
}

.bookmark-btn:hover {
  transform: scale(1.2);
}

.bookmark-btn.bookmarked {
  color: #f59e0b;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .hero-gradient {
    min-height: auto;
    padding: 6rem 1rem 4rem;
  }

  .category-card {
    padding: 1.5rem;
  }

  .category-card .category-icon {
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
  }

  .tool-card {
    padding: 1.25rem;
  }

  .glow-card {
    padding: 1.5rem;
  }

  .search-container input {
    padding: 14px 16px 14px 44px;
    font-size: 0.9rem;
  }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(102, 126, 234, 0.3);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(102, 126, 234, 0.5);
}

/* ---------- Selection ---------- */
::selection {
  background: rgba(102, 126, 234, 0.3);
  color: inherit;
}

/* ---------- Stagger children animation ---------- */
.stagger-children>* {
  opacity: 0;
  transform: translateY(20px);
  animation: slideUp 0.5s ease forwards;
}

.stagger-children>*:nth-child(1) {
  animation-delay: 0.05s;
}

.stagger-children>*:nth-child(2) {
  animation-delay: 0.1s;
}

.stagger-children>*:nth-child(3) {
  animation-delay: 0.15s;
}

.stagger-children>*:nth-child(4) {
  animation-delay: 0.2s;
}

.stagger-children>*:nth-child(5) {
  animation-delay: 0.25s;
}

.stagger-children>*:nth-child(6) {
  animation-delay: 0.3s;
}

.stagger-children>*:nth-child(7) {
  animation-delay: 0.35s;
}

.stagger-children>*:nth-child(8) {
  animation-delay: 0.4s;
}

.stagger-children>*:nth-child(9) {
  animation-delay: 0.45s;
}

.stagger-children>*:nth-child(10) {
  animation-delay: 0.5s;
}

/* ---------- Mobile Nav ---------- */
.mobile-menu {
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-menu.open {
  transform: translateX(0);
}

/* ---------- Page Transition ---------- */
.page-transition {
  animation: fadeIn 0.4s ease;
}

/* ---------- Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---------- Tab styles for tool pages ---------- */
.tab-btn {
  padding: 8px 20px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: none;
  background: transparent;
  color: #64748b;
}

.tab-btn.active {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.tab-btn:hover:not(.active) {
  background: rgba(102, 126, 234, 0.08);
  color: #667eea;
}