@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Poppins:wght@400;500;600;700;800&display=swap');

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

/* ===========================
   BASE LAYER - Resets & Defaults
   =========================== */
@layer base {
  * {
    box-sizing: border-box;
  }

  body {
    @apply font-sans text-charcoal-900 bg-white antialiased;
    line-height: 1.6;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    @apply font-heading font-bold text-charcoal-900;
  }

  h1 {
    @apply text-4xl md:text-5xl;
  }

  h2 {
    @apply text-3xl md:text-4xl;
  }

  h3 {
    @apply text-2xl md:text-3xl;
  }

  h4 {
    @apply text-xl md:text-2xl;
  }

  a {
    @apply text-inherit no-underline;
  }

  img {
    @apply max-w-full h-auto;
  }
}

/* ===========================
   COMPONENT LAYER - Reusable Classes
   =========================== */
@layer components {

  /* --- Container --- */
  .container {
    @apply max-w-7xl mx-auto px-4 sm:px-6 lg:px-8;
  }

  /* --- Buttons --- */
  .btn {
    @apply inline-flex items-center justify-center gap-2 font-semibold text-sm px-6 py-3 rounded-xl transition-all duration-300 cursor-pointer focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed;
  }

  .btn-primary {
    @apply btn bg-gradient-to-r from-brand-500 to-brand-600 text-white shadow-btn hover:shadow-btn-hover hover:-translate-y-0.5 focus:ring-brand-500 active:translate-y-0;
  }

  .btn-secondary {
    @apply btn bg-charcoal-900 text-white hover:bg-charcoal-800 hover:-translate-y-0.5 focus:ring-charcoal-500;
  }

  .btn-outline {
    @apply btn border-2 border-charcoal-200 text-charcoal-900 bg-transparent hover:bg-charcoal-50 hover:border-charcoal-300 focus:ring-charcoal-500;
  }

  .btn-ghost {
    @apply btn text-charcoal-600 bg-transparent hover:bg-charcoal-50 hover:text-charcoal-900;
  }

  .btn-success {
    @apply btn bg-success-500 text-white hover:bg-success-600 hover:-translate-y-0.5 focus:ring-success-500;
  }

  .btn-sm {
    @apply text-xs px-4 py-2 rounded-lg;
  }

  .btn-lg {
    @apply text-base px-8 py-4 rounded-2xl;
  }

  .btn-icon {
    @apply p-2.5 rounded-xl;
  }

  /* --- Glow CTA Button --- */
  .btn-glow {
    position: relative;
    overflow: hidden;
  }

  .btn-glow::after {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(135deg, rgba(230, 57, 70, 0.5), transparent, rgba(230, 57, 70, 0.5));
    border-radius: inherit;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.4s ease;
    filter: blur(10px);
  }

  .btn-glow:hover::after {
    opacity: 1;
    animation: glowPulse 2s ease-in-out infinite;
  }

  /* --- Cards --- */
  .card {
    @apply bg-white rounded-2xl shadow-card border border-gray-100/80 transition-all duration-300 overflow-hidden;
  }

  .card:hover {
    @apply shadow-card-hover -translate-y-1;
  }

  .card-glass {
    @apply bg-white/70 backdrop-blur-xl rounded-2xl border border-white/20 shadow-glass;
  }

  /* --- Badges --- */
  .badge {
    @apply inline-flex items-center px-2.5 py-0.5 rounded-full text-[11px] font-bold uppercase tracking-wider;
  }

  .badge-brand {
    @apply badge bg-brand-50 text-brand-600 border border-brand-100;
  }

  .badge-success {
    @apply badge bg-success-50 text-success-600 border border-green-100;
  }

  .badge-alert {
    @apply badge bg-alert-50 text-alert-600 border border-orange-100;
  }

  .badge-charcoal {
    @apply badge bg-charcoal-50 text-charcoal-600 border border-charcoal-100;
  }

  /* --- Animated Badge --- */
  .badge-animated {
    @apply badge;
    animation: badgePop 0.5s ease-out;
  }

  /* --- Form Inputs --- */
  .input {
    @apply w-full px-4 py-3 rounded-xl border border-gray-200 bg-white text-charcoal-900 text-sm placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-brand-500/20 focus:border-brand-500 transition-all duration-200;
  }

  .input-label {
    @apply block text-sm font-medium text-charcoal-700 mb-1.5;
  }

  .input-error {
    @apply border-brand-500 focus:ring-brand-500/20;
  }

  .select {
    @apply input appearance-none pr-10;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
  }

  /* --- Section Title --- */
  .section-title {
    @apply font-heading text-3xl md:text-4xl font-bold text-charcoal-900 text-center mb-3;
  }

  .section-subtitle {
    @apply text-gray-500 text-center text-base md:text-lg max-w-2xl mx-auto mb-10;
  }

  /* --- Skeleton Loader --- */
  .skeleton {
    @apply bg-gray-200 rounded-xl animate-pulse;
  }

  .skeleton-text {
    @apply skeleton h-4 w-3/4;
  }

  .skeleton-title {
    @apply skeleton h-6 w-1/2;
  }

  .skeleton-image {
    @apply skeleton aspect-square w-full;
  }

  /* --- Dividers --- */
  .divider {
    @apply border-t border-gray-100 my-6;
  }

  /* --- Glass Panel --- */
  .glass-panel {
    @apply bg-white/60 backdrop-blur-lg border border-white/30 shadow-glass rounded-2xl;
  }

  /* --- Glassmorphism Banner --- */
  .glass-banner {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 1rem;
  }
}

/* ===========================
   UTILITY LAYER - Custom Helpers
   =========================== */
@layer utilities {
  .text-gradient {
    @apply bg-clip-text text-transparent bg-gradient-to-r from-brand-500 to-brand-700;
  }

  .gradient-brand {
    @apply bg-gradient-to-r from-brand-500 to-brand-600;
  }

  .gradient-charcoal {
    @apply bg-gradient-to-r from-charcoal-900 to-charcoal-700;
  }

  .gradient-hero {
    @apply bg-gradient-to-br from-charcoal-950 via-charcoal-900 to-brand-900;
  }
}

/* ===========================
   DELIVERY TRUCK ANIMATION
   Truck enters left → pulls text to center → pauses → fades → loops (8s)
   =========================== */
.delivery-animation {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

.delivery-truck {
  font-size: 14px;
  display: inline-block;
  animation: truckPull 8s ease-in-out infinite;
  will-change: transform, opacity;
}

.delivery-text {
  display: inline-block;
  animation: textSlide 8s ease-in-out infinite;
  will-change: transform, opacity;
}

@keyframes truckPull {
  0% {
    transform: translateX(-40px);
    opacity: 0;
  }

  8% {
    transform: translateX(0);
    opacity: 1;
  }

  65% {
    transform: translateX(0);
    opacity: 1;
  }

  80% {
    transform: translateX(0);
    opacity: 0;
  }

  100% {
    transform: translateX(-40px);
    opacity: 0;
  }
}

@keyframes textSlide {
  0% {
    transform: translateX(-50px);
    opacity: 0;
  }

  12% {
    transform: translateX(0);
    opacity: 1;
  }

  65% {
    transform: translateX(0);
    opacity: 1;
  }

  82% {
    transform: translateX(0);
    opacity: 0;
  }

  100% {
    transform: translateX(-50px);
    opacity: 0;
  }
}


/* ===========================
   FLOATING HERO ANIMATION
   =========================== */
.floating-shadow {
  animation: shadowPulse 5s ease-in-out infinite;
}

@keyframes shadowPulse {

  0%,
  100% {
    transform: translateX(-50%) scaleX(1);
    opacity: 0.1;
  }

  50% {
    transform: translateX(-50%) scaleX(0.75);
    opacity: 0.2;
  }
}

/* ===========================
   GLOW PULSE (for CTA buttons)
   =========================== */
@keyframes glowPulse {

  0%,
  100% {
    opacity: 0.6;
    filter: blur(10px);
  }

  50% {
    opacity: 1;
    filter: blur(14px);
  }
}

/* ===========================
   BADGE POP
   =========================== */
@keyframes badgePop {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }

  60% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ===========================
   BELL WIGGLE
   =========================== */
@keyframes wiggle {

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

  15% {
    transform: rotate(12deg);
  }

  30% {
    transform: rotate(-10deg);
  }

  45% {
    transform: rotate(8deg);
  }

  60% {
    transform: rotate(-6deg);
  }

  75% {
    transform: rotate(4deg);
  }

  90% {
    transform: rotate(-2deg);
  }
}

/* ===========================
   NOTIFICATION DROPDOWN SLIDE DOWN
   =========================== */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
  }

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

/* ===========================
   SMOOTH PAGE TRANSITIONS
   =========================== */
main {
  animation: pageIn 0.35s ease-out;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

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

/* ===========================
   REDUCED MOTION
   =========================== */
@media (prefers-reduced-motion: reduce) {

  .delivery-truck,
  .delivery-text,
  .delivery-man,
  .floating-shadow,
  .badge-animated,
  main {
    animation: none !important;
  }

  .btn-glow::after {
    animation: none !important;
  }

  * {
    transition-duration: 0.01ms !important;
  }
}

/* ===========================
   SCROLLBAR
   =========================== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #f8fafc;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ===========================
   SELECTION
   =========================== */
::selection {
  background: rgba(230, 57, 70, 0.15);
  color: #1D3557;
}

/* ===========================
   FLOATING ROBOT HERO
   =========================== */
.hero-robot-container {
  position: relative;
  width: 320px;
  height: 320px;
  will-change: transform;
}

.hero-robot-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  will-change: transform;
  cursor: pointer;
  transition: filter 0.3s ease;
}

.hero-robot-wrapper:hover {
  filter: brightness(1.1);
}

.hero-robot-wrapper:hover .hero-robot-image {
  transform: translateY(-8px) scale(1.04);
  filter: drop-shadow(0 0 20px rgba(230, 57, 70, 0.4));
}

.hero-robot-glow {
  position: absolute;
  inset: -20%;
  background: radial-gradient(ellipse at center,
      rgba(230, 57, 70, 0.15) 0%,
      rgba(230, 57, 70, 0.05) 40%,
      transparent 70%);
  border-radius: 50%;
  z-index: -1;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.hero-robot-wrapper:hover .hero-robot-glow {
  opacity: 1.5;
}

.hero-robot-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  position: relative;
  z-index: 1;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    filter 0.4s ease;
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.3));
  border-radius: 24px;
}

.hero-robot-shadow {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 55%;
  height: 12px;
  background: radial-gradient(ellipse at center,
      rgba(0, 0, 0, 0.2) 0%,
      transparent 70%);
  border-radius: 50%;
  will-change: transform, opacity;
}

.hero-robot-wrapper:hover~.hero-robot-shadow {
  opacity: 0.35 !important;
  transform: translateX(-50%) scaleX(1.15);
}

/* Responsive */
@media (min-width: 1280px) {
  .hero-robot-container {
    width: 380px;
    height: 380px;
  }
}

@media (min-width: 1536px) {
  .hero-robot-container {
    width: 420px;
    height: 420px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

  .hero-robot-wrapper,
  .hero-robot-image,
  .hero-robot-shadow {
    animation: none !important;
    transition: none !important;
  }
}