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

/* ============================================================
   AGRECOL Andes — Panel Administrador
   ============================================================ */

:root {
  --ad-bg:       #0F1A0A;
  --ad-sidebar:  #141F0D;
  --ad-card:     #1C2A14;
  --ad-border:   #2A3D1F;
  --ad-green:    #4C9A1A;
  --ad-green-lt: #B8D98A;
  --ad-green-dk: #2E6B10;
  --ad-muted:    #7A9060;
  --ad-text:     #E8F0DC;
  --ad-text-sub: #8A9E70;
  --ad-white:    #FFFFFF;
  --ad-amber:    #D08000;
  --ad-amber-lt: #3A2800;
  --ad-red:      #C0392B;
  --ad-red-lt:   #3A0D0A;
  --ad-font:     'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --ad-radius:   10px;
  --ad-sidebar-w:200px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body { font-family: var(--ad-font); background: var(--ad-bg); color: var(--ad-text); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
input, select, textarea, button { font-family: inherit; }

/* ============================================================
   LAYOUT
   ============================================================ */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--ad-sidebar-w);
  background: var(--ad-sidebar);
  border-right: 1px solid var(--ad-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-brand {
  padding: 20px 16px 18px;
  border-bottom: 1px solid var(--ad-border);
}

.sidebar-logo {
  display: block;
  background: white;
  padding: 5px 10px;
  border-radius: 6px;
  margin-bottom: 10px;
}

.sidebar-logo img { height: 32px; display: block; }

.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--ad-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ad-muted);
  padding: 12px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--ad-radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--ad-text-sub);
  cursor: pointer;
  transition: background .12s, color .12s;
  margin-bottom: 2px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item i { font-size: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--ad-card); color: var(--ad-text); }
.nav-item.active { background: rgba(76,154,26,.18); color: var(--ad-green-lt); }
.nav-item.active i { color: var(--ad-green); }

.sidebar-footer {
  padding: 14px 8px;
  border-top: 1px solid var(--ad-border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--ad-radius);
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(76,154,26,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: var(--ad-green-lt);
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 12px; font-weight: 600; color: var(--ad-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { font-size: 10px; color: var(--ad-muted); }

.btn-logout {
  background: none;
  border: none;
  color: var(--ad-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 5px;
  transition: color .12s, background .12s;
  display: flex;
}

.btn-logout:hover { color: var(--ad-red); background: var(--ad-red-lt); }
.btn-logout i { font-size: 16px; }

/* ---- MAIN CONTENT ---- */
.main-content {
  margin-left: var(--ad-sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top bar */
.topbar {
  background: var(--ad-sidebar);
  border-bottom: 1px solid var(--ad-border);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 15px; font-weight: 700; color: var(--ad-text); }
.topbar-sub   { font-size: 12px; color: var(--ad-muted); margin-top: 1px; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-date { font-size: 12px; color: var(--ad-muted); }

.topbar-badge {
  font-size: 11px;
  font-weight: 700;
  background: rgba(76,154,26,.18);
  color: var(--ad-green-lt);
  padding: 4px 10px;
  border-radius: 999px;
}

/* Page content */
.page-content {
  padding: 24px 28px 40px;
  flex: 1;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--ad-card);
  border: 1px solid var(--ad-border);
  border-radius: var(--ad-radius);
  padding: 20px;
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ad-text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title i { font-size: 15px; color: var(--ad-green); }

/* ============================================================
   STATS GRID (dashboard)
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.stat-box {
  background: var(--ad-card);
  border: 1px solid var(--ad-border);
  border-radius: var(--ad-radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-box-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-box-label { font-size: 11.5px; font-weight: 600; color: var(--ad-muted); }

.stat-box-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-box-icon i { font-size: 18px; }

.stat-box-icon.green { background: rgba(76,154,26,.15); }
.stat-box-icon.green i { color: var(--ad-green); }
.stat-box-icon.amber { background: var(--ad-amber-lt); }
.stat-box-icon.amber i { color: var(--ad-amber); }
.stat-box-icon.red   { background: var(--ad-red-lt); }
.stat-box-icon.red i { color: var(--ad-red); }
.stat-box-icon.blue  { background: rgba(30,100,168,.2); }
.stat-box-icon.blue i{ color: #5AA8E8; }

.stat-box-num {
  font-size: 28px;
  font-weight: 800;
  color: var(--ad-text);
  line-height: 1;
}

.stat-box-delta {
  font-size: 11px;
  color: var(--ad-muted);
}

/* ============================================================
   TABLAS
   ============================================================ */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead tr { border-bottom: 1px solid var(--ad-border); }

th {
  padding: 10px 14px;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ad-muted);
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(42,61,31,.5);
  color: var(--ad-text);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: rgba(255,255,255,.02); }

.td-muted { color: var(--ad-muted); font-size: 12px; }

/* Badges de estado */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}

.badge-green  { background: rgba(76,154,26,.15); color: var(--ad-green-lt); }
.badge-red    { background: var(--ad-red-lt);    color: #E88080; }
.badge-gray   { background: rgba(42,61,31,.5);   color: var(--ad-muted); }
.badge-amber  { background: var(--ad-amber-lt);  color: #E8B860; }

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--ad-radius);
  border: none;
  cursor: pointer;
  transition: opacity .12s, background .12s;
}

.btn i { font-size: 15px; }
.btn:disabled { opacity: .5; cursor: default; }

.btn-primary   { background: var(--ad-green); color: #fff; }
.btn-primary:hover { background: #5aad22; }

.btn-secondary { background: var(--ad-card); color: var(--ad-text); border: 1px solid var(--ad-border); }
.btn-secondary:hover { background: rgba(42,61,31,.8); }

.btn-danger    { background: var(--ad-red-lt); color: #E88080; border: 1px solid rgba(192,57,43,.3); }
.btn-danger:hover { background: rgba(192,57,43,.25); }

.btn-icon {
  padding: 6px 8px;
  background: none;
  border: 1px solid var(--ad-border);
  border-radius: 7px;
  cursor: pointer;
  color: var(--ad-muted);
  display: inline-flex;
  align-items: center;
  transition: background .12s, color .12s;
}

.btn-icon i { font-size: 15px; }
.btn-icon:hover { background: var(--ad-card); color: var(--ad-text); }
.btn-icon.danger:hover { color: var(--ad-red); border-color: rgba(192,57,43,.4); }

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }

.form-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ad-muted);
}

.form-control {
  font-size: 13.5px;
  padding: 9px 13px;
  background: var(--ad-bg);
  border: 1.5px solid var(--ad-border);
  border-radius: var(--ad-radius);
  color: var(--ad-text);
  width: 100%;
  transition: border-color .12s;
}

.form-control:focus { outline: none; border-color: var(--ad-green); }

.form-control option { background: var(--ad-bg); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--ad-border);
}

.form-feedback {
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 7px;
  margin-bottom: 12px;
}

.form-feedback.ok    { background: rgba(76,154,26,.12); color: var(--ad-green-lt); }
.form-feedback.error { background: var(--ad-red-lt);   color: #E88080; }

/* ============================================================
   PANEL (header + content)
   ============================================================ */
.panel-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title  { font-size: 18px; font-weight: 800; color: var(--ad-text); }
.panel-sub    { font-size: 12.5px; color: var(--ad-muted); margin-top: 2px; }

/* Filtros de la tabla admin */
.table-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-select {
  font-size: 12.5px;
  padding: 7px 28px 7px 10px;
  background: var(--ad-card);
  border: 1.5px solid var(--ad-border);
  border-radius: 8px;
  color: var(--ad-text);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237A9060' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color .12s;
}

.filter-select:focus { outline: none; border-color: var(--ad-green); }

/* Paginación */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  justify-content: center;
}

.page-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1.5px solid var(--ad-border);
  background: none;
  color: var(--ad-text-sub);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}

.page-btn:hover { background: var(--ad-card); color: var(--ad-text); }
.page-btn.active { background: var(--ad-green); color: #fff; border-color: var(--ad-green); }
.page-btn:disabled { opacity: .35; cursor: default; }

/* ============================================================
   MODAL ADMIN
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 3, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-overlay[hidden] { display: none; }

.modal-box {
  background: var(--ad-card);
  border: 1px solid var(--ad-border);
  border-radius: 14px;
  padding: 26px 26px 20px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-box.wide { max-width: 700px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title { font-size: 16px; font-weight: 800; color: var(--ad-text); }

.modal-close-btn {
  background: rgba(42,61,31,.5);
  border: 1px solid var(--ad-border);
  color: var(--ad-muted);
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 7px;
  font-size: 18px;
  line-height: 1;
  transition: background .12s, color .12s;
}

.modal-close-btn:hover { background: var(--ad-red-lt); color: var(--ad-red); }

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0A1205 0%, #141F0D 100%);
  padding: 20px;
}

.login-box {
  background: var(--ad-card);
  border: 1px solid var(--ad-border);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}

.login-logo {
  background: white;
  padding: 6px 14px;
  border-radius: 8px;
  margin-bottom: 22px;
  display: inline-block;
}

.login-logo img { height: 36px; display: block; }

.login-title { font-size: 22px; font-weight: 800; color: var(--ad-text); margin-bottom: 4px; }
.login-sub   { font-size: 13px; color: var(--ad-muted); margin-bottom: 28px; }

.login-error-msg {
  background: var(--ad-red-lt);
  color: #E88080;
  font-size: 12.5px;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  border: 1px solid rgba(192,57,43,.3);
}

/* Quimicos en el editor de resultados */
.quimico-editor-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--ad-border);
}

.quimico-editor-row:last-child { border-bottom: none; }

.quimico-editor-head {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ad-border);
  margin-bottom: 4px;
}

.qe-label {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ad-muted);
}

/* ============================================================
   TOP COMPUESTOS (dashboard)
   ============================================================ */
.top-compound-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(42,61,31,.5);
}

.top-compound-row:last-child { border-bottom: none; }

.tc-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(76,154,26,.15);
  color: var(--ad-green-lt);
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tc-name {
  flex: 1;
  font-size: 12.5px;
  color: var(--ad-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tc-bar { flex: 1; height: 6px; background: rgba(42,61,31,.8); border-radius: 999px; overflow: hidden; }
.tc-bar-fill { height: 100%; background: var(--ad-green); border-radius: 999px; }

.tc-count { font-size: 12px; font-weight: 700; color: var(--ad-green-lt); min-width: 28px; text-align: right; }

/* Responsive */
@media (max-width: 768px) {
  :root { --ad-sidebar-w: 0px; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .quimico-editor-row, .quimico-editor-head { grid-template-columns: 1fr 1fr 1fr auto; }
}


/* Leaflet mapa picker en modal de feria */
#ff-mapa-picker { cursor: crosshair; }
#ff-mapa-picker .leaflet-grab { cursor: crosshair; }
#ff-mapa-picker .leaflet-container { background: #e8f0dc; }
.leaflet-control-attribution { display: none !important; }
