/* ═══════════════════════════════════════════════════════════
   BASE
   ═══════════════════════════════════════════════════════════ */
html { scroll-behavior: smooth; }

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: #080d17;
  color: #e2e8f0;
  transition: background-color .4s ease, color .4s ease;
  min-height: 100vh;
}

/* Fondo con capas de gradientes (tema oscuro) */
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(900px 500px at 15% -5%,  rgba(16,185,129,.20), transparent 55%),
    radial-gradient(700px 400px at 100% 5%,  rgba(99,102,241,.14), transparent 55%),
    radial-gradient(800px 500px at 50% 110%, rgba(6,182,212,.10), transparent 60%);
  pointer-events: none;
  z-index: 0;
  transition: opacity .4s ease;
}

/* Textura de grano sutil */
body::after {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: .035;
  pointer-events: none;
  z-index: 0;
  mix-blend-mode: overlay;
}

/* Tema claro */
html:not(.dark) body {
  background-color: #f6f8fb;
  color: #1e293b;
}
html:not(.dark) body::before {
  background:
    radial-gradient(900px 500px at 15% -5%,  rgba(16,185,129,.30), transparent 55%),
    radial-gradient(700px 400px at 100% 5%,  rgba(99,102,241,.15), transparent 55%),
    radial-gradient(800px 500px at 50% 110%, rgba(251,191,36,.12), transparent 60%);
}
html:not(.dark) body::after { opacity: .025; }

.content { position: relative; z-index: 1; }

/* ═══════════════════════════════════════════════════════════
   GLASS
   ═══════════════════════════════════════════════════════════ */
.glass {
  background: rgba(15,23,42,.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid rgba(255,255,255,.06);
}
html:not(.dark) .glass {
  background: rgba(255,255,255,.78);
  border-color: rgba(15,23,42,.06);
}

/* ═══════════════════════════════════════════════════════════
   PANELES (tarjetas)
   ═══════════════════════════════════════════════════════════ */
.panel {
  position: relative;
  background: linear-gradient(180deg, rgba(30,41,59,.85) 0%, rgba(15,23,42,.85) 100%);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,.3), 0 20px 40px -20px rgba(0,0,0,.5);
  backdrop-filter: blur(12px);
  transition: all .35s cubic-bezier(.16,1,.3,1);
}
.panel:hover { border-color: rgba(16,185,129,.22); }

.panel-accent::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(16,185,129,.4), transparent 40%, transparent 60%, rgba(99,102,241,.3));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
  opacity: .8;
}

html:not(.dark) .panel {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-color: rgba(15,23,42,.06);
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 20px 40px -24px rgba(15,23,42,.12);
}

/* ═══════════════════════════════════════════════════════════
   INPUTS
   ═══════════════════════════════════════════════════════════ */
.input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(2,6,23,.5);
  padding: .65rem .9rem;
  font-size: .875rem;
  color: #e2e8f0;
  outline: none;
  transition: all .2s ease;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.3);
}
.input::placeholder { color: #64748b; }
.input:hover { border-color: rgba(255,255,255,.14); }
.input:focus {
  border-color: rgba(16,185,129,.6);
  box-shadow: 0 0 0 4px rgba(16,185,129,.15), inset 0 1px 2px rgba(0,0,0,.3);
  background: rgba(2,6,23,.7);
}

html:not(.dark) .input {
  background: #ffffff;
  border-color: #e2e8f0;
  color: #1e293b;
  box-shadow: inset 0 1px 2px rgba(15,23,42,.03);
}
html:not(.dark) .input:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 4px rgba(16,185,129,.15);
}

/* Select con flecha única (arreglado) */
select.input {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  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='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right .9rem center !important;
  background-size: 16px 16px !important;
  padding-right: 2.4rem !important;
}
html:not(.dark) select.input {
  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='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
}

label.field {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: .5rem;
}
html:not(.dark) label.field { color: #475569; }

/* ═══════════════════════════════════════════════════════════
   BOTÓN PRIMARIO
   ═══════════════════════════════════════════════════════════ */
.btn-primary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  width: 100%;
  padding: .85rem 1.5rem;
  border-radius: 14px;
  font-weight: 700;
  font-size: .875rem;
  color: #022c22;
  background: linear-gradient(180deg, #6ee7b7 0%, #10b981 100%);
  box-shadow:
    0 0 0 1px rgba(16,185,129,.5),
    0 10px 24px -6px rgba(16,185,129,.5),
    inset 0 1px 0 rgba(255,255,255,.35),
    inset 0 -1px 0 rgba(0,0,0,.1);
  transition: all .25s cubic-bezier(.16,1,.3,1);
  cursor: pointer;
  overflow: hidden;
  border: none;
}
.btn-primary::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 20%, rgba(255,255,255,.35) 45%, transparent 70%);
  transform: translateX(-150%);
  transition: transform .8s ease;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow:
    0 0 0 1px rgba(16,185,129,.7),
    0 16px 32px -8px rgba(16,185,129,.65),
    inset 0 1px 0 rgba(255,255,255,.4);
}
.btn-primary:hover::after { transform: translateX(150%); }
.btn-primary:active { transform: translateY(0) scale(.985); }

/* ═══════════════════════════════════════════════════════════
   BARRA LUNAR
   ═══════════════════════════════════════════════════════════ */
.moon-bar {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(400px 200px at 10% 0%, rgba(99,102,241,.25), transparent 60%),
    radial-gradient(500px 300px at 90% 100%, rgba(16,185,129,.15), transparent 60%),
    linear-gradient(135deg, #0b1220 0%, #0f172a 100%);
  border: 1px solid rgba(99,102,241,.2);
  box-shadow:
    0 1px 2px rgba(0,0,0,.4),
    0 24px 48px -16px rgba(99,102,241,.3),
    inset 0 1px 0 rgba(255,255,255,.06);
}
html:not(.dark) .moon-bar {
  background:
    radial-gradient(400px 200px at 10% 0%, rgba(99,102,241,.18), transparent 60%),
    radial-gradient(500px 300px at 90% 100%, rgba(16,185,129,.12), transparent 60%),
    linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

/* Estrellas decorativas */
.stars-field {
  position: absolute; inset: 0;
  pointer-events: none; overflow: hidden;
}
.stars-field .star {
  position: absolute;
  background: white;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(255,255,255,.9);
  animation: pulseSoft 3s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════
   PROGRESO
   ═══════════════════════════════════════════════════════════ */
.progress-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(2,6,23,.6);
  box-shadow: inset 0 1px 3px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.04);
  overflow: hidden;
}
html:not(.dark) .progress-track {
  background: #e2e8f0;
  box-shadow: inset 0 1px 3px rgba(15,23,42,.08);
}
.progress-fill {
  position: relative;
  height: 100%;
  border-radius: 999px;
  transition: width .9s cubic-bezier(.16,1,.3,1);
  overflow: hidden;
  box-shadow: 0 0 12px rgba(16,185,129,.6);
}
.progress-fill::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 30%, rgba(255,255,255,.5) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmer 3s linear infinite;
}

/* ═══════════════════════════════════════════════════════════
   BOTÓN DE TEMA
   ═══════════════════════════════════════════════════════════ */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(2,6,23,.5);
  color: #94a3b8;
  cursor: pointer;
  transition: all .25s ease;
}
.theme-toggle:hover {
  border-color: rgba(16,185,129,.4);
  color: #6ee7b7;
  box-shadow: 0 0 20px -4px rgba(16,185,129,.4);
}
html:not(.dark) .theme-toggle {
  background: #ffffff;
  border-color: #e2e8f0;
  color: #475569;
}

/* ═══════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .25rem .65rem;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  border: 1px solid;
  backdrop-filter: blur(4px);
}

/* ═══════════════════════════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(100,116,139,.3);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(100,116,139,.5);
  background-clip: content-box;
}

/* ═══════════════════════════════════════════════════════════
   KEYFRAMES GLOBALES
   ═══════════════════════════════════════════════════════════ */
@keyframes pulseSoft {
  0%, 100% { opacity: 1; }
  50%      { opacity: .75; }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ═══════════════════════════════════════════════════════════
   AJUSTES DE TEMA CLARO
   Sobrescribe clases Tailwind pensadas solo para oscuro,
   pero solo dentro de .panel y header (la barra lunar queda intacta).
   ═══════════════════════════════════════════════════════════ */

/* Textos primarios */
html:not(.dark) :is(.panel, header) .text-slate-100 { color: #0f172a !important; }
html:not(.dark) :is(.panel, header) .text-slate-200 { color: #1e293b !important; }
html:not(.dark) :is(.panel, header) .text-slate-300 { color: #334155 !important; }
html:not(.dark) :is(.panel, header) .text-slate-400 { color: #475569 !important; }
html:not(.dark) :is(.panel, header) .text-slate-500 { color: #64748b !important; }

/* Fondos internos translúcidos (bloques de fechas) */
html:not(.dark) .panel .bg-white\/\[\.03\] {
  background-color: rgba(15,23,42,.035) !important;
}
html:not(.dark) .panel .bg-white\/\[\.06\] {
  background-color: rgba(15,23,42,.06) !important;
}

/* Bordes internos */
html:not(.dark) .panel .border-white\/\[\.06\] {
  border-color: rgba(15,23,42,.08) !important;
}
html:not(.dark) .panel .border-white\/\[\.08\] {
  border-color: rgba(15,23,42,.10) !important;
}
html:not(.dark) .panel .border-white\/5 {
  border-color: rgba(15,23,42,.08) !important;
}

/* Badges de variedad — texto oscuro del color del cultivo */
html:not(.dark) .panel .badge.bg-amber-400\/10   { color: #92400e !important; }
html:not(.dark) .panel .badge.bg-emerald-400\/10 { color: #065f46 !important; }
html:not(.dark) .panel .badge.bg-yellow-400\/10  { color: #854d0e !important; }
html:not(.dark) .panel .badge.bg-lime-400\/10    { color: #3f6212 !important; }

/* Textos de color del cultivo dentro de paneles */
html:not(.dark) .panel .text-amber-300   { color: #b45309 !important; }
html:not(.dark) .panel .text-emerald-300 { color: #047857 !important; }
html:not(.dark) .panel .text-yellow-300  { color: #a16207 !important; }
html:not(.dark) .panel .text-lime-300    { color: #4d7c0f !important; }

/* Header y botones */
html:not(.dark) header .text-slate-100 { color: #0f172a !important; }
html:not(.dark) header .text-slate-500 { color: #64748b !important; }

html:not(.dark) .text-brand-300 { color: #047857 !important; }
html:not(.dark) .text-brand-200 { color: #065f46 !important; }

/* Título de sección "Mis siembras" */
html:not(.dark) main .text-slate-100 { color: #0f172a !important; }

/* Estado vacío */
html:not(.dark) .panel .text-slate-400 { color: #475569 !important; }
html:not(.dark) .panel .text-slate-500 { color: #64748b !important; }

/* ═══════════════════════════════════════════════════════════
   LAYOUT DE ESCRITORIO (mejoras)
   ═══════════════════════════════════════════════════════════ */

/* Formulario sticky: que tenga scroll interno si es muy alto */
@media (min-width: 1024px) {
  main > section:first-child {
    max-height: calc(100vh - 7rem);
    overflow-y: auto;
  }
  main > section:first-child::-webkit-scrollbar { width: 6px; }
  main > section:first-child::-webkit-scrollbar-thumb {
    background: rgba(100,116,139,.2);
    border-radius: 10px;
  }
}

/* Barra lunar más amplia en escritorio */
@media (min-width: 1024px) {
  .moon-bar {
    padding: 1.75rem 2rem !important;
  }
  .moon-bar #moonIcon {
    font-size: 4.5rem !important;
  }
  .moon-bar #moonName {
    font-size: 1.5rem !important;
  }
}

/* Footer separado visualmente en escritorio */
@media (min-width: 1024px) {
  footer {
    border-top: 1px solid rgba(255,255,255,.05);
    margin-top: 1rem;
  }
  html:not(.dark) footer {
    border-top-color: rgba(15,23,42,.06);
  }
}