/* ==========================================================================
   INVER.INDEX · Hoja de estilos principal
   Diseño responsive (móvil primero) para el panel de gestión del invernadero
   ========================================================================== */

/* ------------------------------- Variables ------------------------------ */
:root {
  --primary:        #1b7a3d;
  --primary-dark:   #145c2e;
  --primary-light:  #e7f5ec;
  --primary-ring:   rgba(27, 122, 61, .25);
  --accent:         #f0a500;
  --bg:             #f2f5f2;
  --card:           #ffffff;
  --text:           #1e2a23;
  --muted:          #6b7a71;
  --border:         #e2e8e4;
  --sidebar-bg:     #10331d;
  --sidebar-bg2:    #17492a;
  --danger:         #d64545;
  --warning:        #e8a33d;
  --success:        #1b7a3d;
  --info:           #2f80ed;
  --purple:         #7a3dbd;
  --orange:         #e8620c;
  --dark:           #2a2f2c;
  --radius:         14px;
  --radius-sm:      9px;
  --shadow:         0 1px 2px rgba(16, 51, 29, .06), 0 6px 18px rgba(16, 51, 29, .06);
  --shadow-lg:      0 12px 34px rgba(16, 51, 29, .18);
  --sidebar-w:      256px;
  --topbar-h:       62px;
}

/* -------------------------------- Reset -------------------------------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

/* ------------------------------- Layout -------------------------------- */
.layout { min-height: 100vh; }
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin .25s ease;
}
.content { padding: 22px; flex: 1; max-width: 1400px; width: 100%; }

/* ------------------------------- Sidebar ------------------------------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg2));
  color: #d9e7de;
  display: flex;
  flex-direction: column;
  z-index: 60;
  transition: transform .25s ease;
  overflow-y: auto;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar__brand img { width: 42px; height: 42px; object-fit: contain; border-radius: 10px; background: rgba(255,255,255,.08); padding: 4px; }
.sidebar__brand strong { color: #fff; font-size: 1.05rem; display: block; letter-spacing: .5px; }
.sidebar__brand small { color: #9dc0a8; font-size: .72rem; }
.sidebar__nav { padding: 10px 10px 30px; display: flex; flex-direction: column; gap: 2px; }
.sidebar__title {
  font-size: .68rem; text-transform: uppercase; letter-spacing: 1.4px;
  color: #7fa88c; margin: 16px 12px 6px; font-weight: 700;
}
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 9px;
  color: #cfe0d5; font-size: .92rem; text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.25); font-weight: 600; }
.nav-link .ico { width: 20px; text-align: center; font-size: 1rem; }
.sidebar__foot { margin-top: auto; padding: 14px; font-size: .72rem; color: #80a68d; border-top: 1px solid rgba(255,255,255,.08); }

/* -------------------------------- Topbar ------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
}
.topbar__title { font-weight: 700; font-size: 1.02rem; }
.topbar__spacer { flex: 1; }
.icon-btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
  font-size: 1.15rem; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--primary-light); border-color: var(--primary); }
.menu-btn { display: none; }
.user-chip { display: flex; align-items: center; gap: 9px; }
.user-chip img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid var(--primary-light); }
.user-chip .who { line-height: 1.1; }
.user-chip .who b { display: block; font-size: .84rem; }
.user-chip .who span { font-size: .72rem; color: var(--muted); text-transform: capitalize; }

/* ------------------------------ Page head ------------------------------ */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); font-size: .88rem; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* -------------------------------- Cards -------------------------------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 18px;
}
.card__head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card__head h2, .card__head h3 { margin: 0; }
.card__head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.card--flush { padding: 0; overflow: hidden; }

/* ------------------------------ Grid / stats --------------------------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; display: flex; gap: 14px; align-items: center;
}
.stat__ico {
  width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
  background: var(--primary-light); color: var(--primary);
}
.stat__ico.bg-info   { background:#e6f0fd; color: var(--info); }
.stat__ico.bg-warn   { background:#fdf1e0; color: var(--warning); }
.stat__ico.bg-danger { background:#fbe9e9; color: var(--danger); }
.stat__ico.bg-purple { background:#f1e9fb; color: var(--purple); }
.stat__body { min-width: 0; }
.stat__val { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.stat__lbl { font-size: .8rem; color: var(--muted); }
.stat__meta { font-size: .75rem; color: var(--muted); margin-top: 2px; }

/* ------------------------------- Buttons ------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: 10px; border: 1px solid transparent;
  font-size: .9rem; font-weight: 600; cursor: pointer; text-decoration: none;
  background: #eef2ef; color: var(--text); transition: filter .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.96); text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #4a3200; }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: .8rem; border-radius: 8px; }
.btn-lg { padding: 12px 22px; font-size: 1rem; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* -------------------------------- Forms -------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px 16px; }
.form-grid .col-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: .82rem; font-weight: 600; color: #3c4a42; }
.field .hint { font-size: .74rem; color: var(--muted); }
.req { color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=tel], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; color: var(--text); background: #fff; transition: border .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring);
}
textarea { min-height: 90px; resize: vertical; }
input[type=file] { padding: 8px; background: #fafbfa; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.check-line { display: flex; align-items: center; gap: 8px; }
.check-line input { width: auto; }

/* ------------------------------- Tables -------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 620px; }
table.table th, table.table td { padding: 11px 13px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.table thead th { background: #f7f9f7; font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); position: sticky; top: 0; }
table.table tbody tr:hover { background: #fafcfa; }
table.table td .thumb { width: 44px; height: 44px; border-radius: 9px; object-fit: cover; border: 1px solid var(--border); }
table.table td.num, table.table th.num { text-align: right; white-space: nowrap; }
.table-actions { display: flex; gap: 6px; }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .big { font-size: 2.4rem; margin-bottom: 6px; }

/* ------------------------------- Badges -------------------------------- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; text-transform: capitalize;
  background: #eef2ef; color: #43514a; white-space: nowrap;
}
.badge-success  { background: #e3f4e9; color: #14663a; }
.badge-danger   { background: #fbe9e9; color: #a52a2a; }
.badge-warning  { background: #fdf1e0; color: #9a6100; }
.badge-info     { background: #e6f0fd; color: #1c5fae; }
.badge-primary  { background: #e3eff9; color: #145c8e; }
.badge-purple   { background: #f1e9fb; color: #5c2a94; }
.badge-orange   { background: #fdece0; color: #a8410a; }
.badge-secondary{ background: #eef2ef; color: #4c5a52; }
.badge-dark     { background: #2a2f2c; color: #fff; }

/* ------------------------------- Alerts -------------------------------- */
.alert {
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 14px;
  border: 1px solid; font-size: .9rem; display: flex; gap: 10px; align-items: flex-start;
}
.alert-success { background: #e9f8ef; border-color: #b9e6c9; color: #14663a; }
.alert-danger  { background: #fdeeee; border-color: #f3c6c6; color: #9c2626; }
.alert-warning { background: #fdf5e8; border-color: #f0dcb2; color: #8a5a00; }
.alert-info    { background: #eaf1fd; border-color: #c2d6f5; color: #1c5fae; }
.flash-wrap { margin-bottom: 6px; }

/* -------------------------- Panel colapsable --------------------------- */
.panel { display: none; }
.panel.open { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; } }
.panel-head { display: flex; align-items: center; margin-bottom: 14px; gap: 10px; }
.panel-head h3 { margin: 0; }

/* --------------------------- Filtros / buscar -------------------------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { min-width: 160px; flex: 1 1 160px; }
.filters .field.grow { flex: 2 1 240px; }

/* ------------------------------- Charts -------------------------------- */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 190px; padding: 10px 4px 0; }
.bars__item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; min-width: 0; }
.bars__bar {
  width: 100%; max-width: 46px; border-radius: 7px 7px 0 0;
  background: linear-gradient(180deg, #35a05c, var(--primary));
  min-height: 3px; transition: height .4s ease;
}
.bars__item span { font-size: .68rem; color: var(--muted); text-align: center; }
.bars__val { font-size: .72rem; font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: .8rem; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.progress { height: 9px; border-radius: 999px; background: #eef2ef; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }

/* -------------------------------- Listas ------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.list li:last-child { border-bottom: 0; }
.list .ico { width: 38px; height: 38px; border-radius: 10px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .meta { font-size: .78rem; color: var(--muted); }

/* ----------------------------- Product cards --------------------------- */
.prod { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.prod img { width: 100%; height: 158px; object-fit: cover; background: #eef2ef; }
.prod__body { padding: 13px 14px 15px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.prod__body h3 { margin: 0; font-size: 1rem; }
.prod__body .meta { font-size: .8rem; color: var(--muted); }
.prod__foot { margin-top: auto; padding-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------ Auth (login) --------------------------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 22px;
  background: radial-gradient(1200px 500px at 10% -10%, #1e7a44, transparent),
              radial-gradient(900px 500px at 110% 110%, #10331d, transparent), #0f2a19;
}
.auth-card {
  width: 100%; max-width: 440px; background: #fff; border-radius: 20px;
  box-shadow: var(--shadow-lg); padding: 30px 26px; margin: auto;
}
.auth-card .brand { text-align: center; margin-bottom: 18px; }
.auth-card .brand img { width: 74px; height: 74px; margin: 0 auto 8px; }
.auth-card .brand h1 { font-size: 1.4rem; margin: 0; }
.auth-card .brand p { color: var(--muted); font-size: .86rem; margin: 4px 0 0; }
.auth-card .form-actions .btn { width: 100%; }
.auth-note { text-align: center; font-size: .87rem; color: var(--muted); margin-top: 16px; }

/* ----------------------------- Backdrop / nav -------------------------- */
.backdrop {
  position: fixed; inset: 0; background: rgba(8, 25, 14, .5);
  opacity: 0; visibility: hidden; transition: opacity .25s; z-index: 50;
}
body.nav-open .backdrop { opacity: 1; visibility: visible; }

/* ------------------------------ Utilidades ----------------------------- */
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.flex { display: flex; gap: 10px; } .flex-wrap { flex-wrap: wrap; } .items-center { align-items: center; }
.between { justify-content: space-between; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #eef2ef; border-radius: 999px; padding: 4px 11px; font-size: .78rem; }
.hide { display: none !important; }

/* ------------------------------ Responsive ----------------------------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 15px; }
  .user-chip .who { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .col-2 { grid-column: span 1; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: 1fr; }
  .page-head .actions { width: 100%; }
  .btn { padding: 9px 12px; }
  h1 { font-size: 1.3rem; }
  .stat__val { font-size: 1.3rem; }
  .card { padding: 15px; }
}

/* Impresión (reportes) */
@media print {
  .sidebar, .topbar, .no-print, .backdrop { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; }
  body { background: #fff; }
}
