/* Modern CSS for AgroPredict AI - Premium Agricultural Intelligence Platform */

/* ===========================
   CSS Variables & Root Setup
   =========================== */
:root {
  /* Color System */
  --emerald-50: #ecfdf5;
  --emerald-100: #d1fae5;
  --emerald-200: #a7f3d0;
  --emerald-300: #6ee7b7;
  --emerald-400: #34d399;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --emerald-800: #065f46;
  --emerald-900: #064e3b;
  
  --sky-50: #f0f9ff;
  --sky-100: #e0f2fe;
  --sky-200: #bae6fd;
  --sky-300: #7dd3fc;
  --sky-400: #38bdf8;
  --sky-500: #0ea5e9;
  --sky-600: #0284c7;
  --sky-700: #0369a1;
  
  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-200: #fde68a;
  --amber-300: #fcd34d;
  --amber-400: #fbbf24;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
  --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  --shadow-glow: 0 0 50px rgba(16, 185, 129, 0.3);
  
  /* Animation Timing */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ===========================
   Global Styles
   =========================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: #1f2937;
}

/* ===========================
   Typography
   =========================== */
.font-display {
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  font-weight: 700;
  line-height: 1.2;
}

/* ===========================
   Glass Morphism Effects
   =========================== */
.glass {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.glass-dark {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ===========================
   Navigation Styles
   =========================== */
.nav-link {
  position: relative;
  overflow: hidden;
}

.nav-link::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--emerald-500), var(--emerald-600));
  transition: width var(--transition-base);
}

.nav-link:hover::before,
.nav-link.active::before {
  width: 100%;
}

.nav-link.active {
  color: var(--emerald-600);
  background-color: var(--emerald-50);
}

/* ===========================
   Form Controls
   =========================== */
.form-select,
input[type="text"],
input[type="email"],
input[type="number"],
textarea {
  appearance: none;
  background-image: none;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  line-height: 1.5;
  transition: all var(--transition-base);
  width: 100%;
}

.form-select:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--emerald-500);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

/* Choices.js Custom Styling */
.choices {
  position: relative;
}

.choices__inner {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  min-height: 48px;
  transition: all var(--transition-base);
}

.choices__inner:hover {
  background: #f3f4f6;
}

.choices.is-focused .choices__inner {
  border-color: var(--emerald-500);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.choices__list--dropdown {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  margin-top: 0.5rem;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.choices__item--selectable {
  padding: 0.75rem 1rem;
  transition: all var(--transition-fast);
}

.choices__item--selectable.is-highlighted {
  background: var(--emerald-50);
  color: var(--emerald-700);
}

/* ===========================
   Button Styles
   =========================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  font-weight: 500;
  font-size: 1rem;
  transition: all var(--transition-base);
  cursor: pointer;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--emerald-500), var(--emerald-600));
  color: white;
  box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.3);
}

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

.btn-primary:active {
  transform: translateY(0);
}

/* ===========================
   Card Components
   =========================== */
.card {
  background: white;
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.metric-card {
  background: linear-gradient(135deg, white, #f9fafb);
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  padding: 1.25rem;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--emerald-500), var(--sky-500));
  opacity: 0;
  transition: opacity var(--transition-base);
}

.metric-card:hover::before {
  opacity: 1;
}

/* ===========================
   Loading States
   =========================== */
.skeleton {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

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

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e5e7eb;
  border-top-color: var(--emerald-500);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===========================
   Chat Interface Styles
   =========================== */
#chat-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
}

#chat-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--emerald-500), var(--emerald-600));
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 25px -5px rgba(16, 185, 129, 0.4);
  transition: all var(--transition-spring);
  position: relative;
  overflow: hidden;
}

#chat-toggle::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
  opacity: 0;
  transition: opacity var(--transition-base);
}

#chat-toggle:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 15px 30px -5px rgba(16, 185, 129, 0.5);
}

#chat-toggle:hover::after {
  opacity: 1;
}

#chat-box {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 2rem);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: white;
  border-radius: 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  transform-origin: bottom right;
  transition: all var(--transition-spring);
}

#chat-box.hidden {
  transform: scale(0.95) translateY(20px);
  opacity: 0;
  pointer-events: none;
}

.chat-header {
  background: linear-gradient(135deg, var(--emerald-500), var(--emerald-600));
  color: white;
  padding: 1rem 1.25rem;
  border-radius: 1.5rem 1.5rem 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-message {
  padding: 0.75rem 1rem;
  margin: 0.5rem;
  border-radius: 1rem;
  max-width: 80%;
  animation: messageSlide 0.3s ease-out;
}

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

.chat-message.user {
  background: linear-gradient(135deg, var(--emerald-500), var(--emerald-600));
  color: white;
  margin-left: auto;
  border-bottom-right-radius: 0.25rem;
}

.chat-message.bot {
  background: #f3f4f6;
  color: #1f2937;
  margin-right: auto;
  border-bottom-left-radius: 0.25rem;
}

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

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

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

.animate-float {
  animation: float 6s ease-in-out infinite;
}

.animate-pulse-glow {
  animation: pulse-glow 2s ease-in-out infinite;
}

.animate-slide-up {
  animation: slide-up 0.5s ease-out;
}

/* ===========================
   Responsive Design
   =========================== */
@media (max-width: 768px) {
  #chat-container {
    bottom: 1rem;
    right: 1rem;
  }
  
  #chat-box {
    width: calc(100vw - 2rem);
    height: calc(100vh - 100px);
    bottom: 70px;
  }
  
  .nav-link span {
    display: none;
  }
  
  .nav-link i {
    margin-right: 0;
  }
}

@media (max-width: 640px) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
  
  .card {
    padding: 1rem;
  }
  
  .btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
  }
}

/* ===========================
   Accessibility
   =========================== */
:focus-visible {
  outline: 2px solid var(--emerald-500);
  outline-offset: 2px;
}

.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;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .glass {
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #000;
  }
  
  .btn-primary {
    background: var(--emerald-700);
    border: 2px solid var(--emerald-900);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===========================
   Print Styles
   =========================== */
@media print {
  #chat-container,
  .no-print,
  nav,
  button {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
  
  .glass {
    background: white;
    border: 1px solid #000;
  }
}

/* ===========================
   Dark Mode Support (Future)
   =========================== */
@media (prefers-color-scheme: dark) {
  /* Dark mode styles can be added here when implementing dark theme */
}
