/* ============================================================
   BEET-EL — Estilos Globales v5
   ============================================================ */

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

:root {
  --green-deep:   #1a2e1a;
  --green-mid:    #2d5a27;
  --green-bright: #4a8c3f;
  --green-light:  #7ec87a;
  --green-pale:   #d4edcc;
  --amber:        #e8a825;
  --amber-light:  #f5d78e;
  --red:          #c0392b;
  --red-light:    #f4b8b3;
  --sky:          #3a7ca5;
  --sky-light:    #c5dded;
  --bg:           #f5f2eb;
  --bg-card:      #ffffff;
  --text:         #1a2e1a;
  --text-muted:   #6b7c6b;
  --border:       #d0d8c8;
  --shadow:       0 2px 12px rgba(26,46,26,0.08);
  --shadow-lg:    0 8px 32px rgba(26,46,26,0.14);
  --font:         'Inter', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  width: 240px; min-height: 100vh;
  background: var(--green-deep);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0;
  z-index: 100; transition: transform 0.3s;
}
.sidebar-logo { padding: 28px 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-logo h1 { font-family: var(--font); font-weight: 800; font-size: 20px; color: var(--green-light); letter-spacing: -0.5px; }
.sidebar-logo a { text-decoration: none; }
.sidebar-logo span { font-size: 11px; color: rgba(255,255,255,0.45); letter-spacing: 1.5px; text-transform: uppercase; display: block; margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 16px 0; }
.nav-section { padding: 8px 16px 4px; font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: rgba(255,255,255,0.3); font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: rgba(255,255,255,0.65); cursor: pointer; font-size: 13.5px; transition: all 0.2s; border-left: 3px solid transparent; margin: 1px 0; text-decoration: none; font-weight: 400; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: rgba(126,200,122,0.15); color: var(--green-light); border-left-color: var(--green-light); font-weight: 500; }
.nav-item .icon { font-size: 17px; width: 20px; text-align: center; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 11px; color: rgba(255,255,255,0.3); }
.overlay-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 90; display: none; }
.overlay-bg.open { display: block; }

/* ── MAIN ───────────────────────────────────────────────── */
.main { margin-left: 240px; flex: 1; min-height: 100vh; }

/* ── TOPBAR ─────────────────────────────────────────────── */
.topbar { background: var(--bg-card); border-bottom: 1px solid var(--border); padding: 14px 32px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.topbar-title { font-weight: 700; font-size: 17px; color: var(--green-deep); letter-spacing: -0.3px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.hamburger { display: none; background: none; border: none; cursor: pointer; font-size: 22px; color: var(--green-deep); }

/* ── CONTENT ────────────────────────────────────────────── */
.content { padding: 28px 32px; }

/* ── PAGE HEADER ────────────────────────────────────────── */
.page-header { margin-bottom: 24px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.page-header h2 { font-weight: 800; font-size: 24px; color: var(--green-deep); letter-spacing: -0.5px; }
.page-header p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── STAT CARDS ─────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--bg-card); border-radius: 14px; padding: 20px; border: 1px solid var(--border); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; transition: transform 0.2s, box-shadow 0.2s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon { font-size: 28px; margin-bottom: 4px; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600; }
.stat-value { font-size: 32px; font-weight: 800; color: var(--green-deep); letter-spacing: -1px; line-height: 1; }
.stat-card.green { border-left: 4px solid var(--green-bright); }
.stat-card.amber { border-left: 4px solid var(--amber); }
.stat-card.red   { border-left: 4px solid var(--red); }
.stat-card.sky   { border-left: 4px solid var(--sky); }

/* ── CARDS ──────────────────────────────────────────────── */
.card { background: var(--bg-card); border-radius: 14px; border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 20px; }
.card-header { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.card-title { font-weight: 700; font-size: 14px; color: var(--green-deep); letter-spacing: -0.2px; }
.card-body { padding: 24px; }

/* ── BUTTONS ────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; transition: all 0.2s; font-family: var(--font); text-decoration: none; letter-spacing: -0.1px; }
.btn-primary { background: var(--green-mid); color: white; }
.btn-primary:hover { background: var(--green-bright); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--green-pale); }
.btn-amber { background: var(--amber); color: #1a1a00; }
.btn-red { background: var(--red); color: white; }
.btn-red:hover { filter: brightness(1.1); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

/* ── FORMS ──────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12.5px; font-weight: 500; color: var(--text-muted); }
input, select, textarea { border: 1.5px solid var(--border); border-radius: 8px; padding: 9px 13px; font-size: 13.5px; font-family: var(--font); color: var(--text); background: var(--bg); outline: none; transition: border-color 0.2s, box-shadow 0.2s; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--green-bright); box-shadow: 0 0 0 3px rgba(74,140,63,0.12); background: white; }
textarea { min-height: 80px; resize: vertical; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* ── TABLE ──────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 14px; text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); border-bottom: 2px solid var(--border); background: var(--bg); cursor: pointer; user-select: none; white-space: nowrap; font-weight: 600; }
th:hover { color: var(--green-bright); }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tr:hover td { background: rgba(74,140,63,0.04); }
tr:last-child td { border-bottom: none; }

/* ── BADGES ─────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 100px; font-size: 11.5px; font-weight: 600; letter-spacing: -0.1px; }
.badge-vivo    { background: var(--green-pale); color: var(--green-mid); }
.badge-vendido { background: var(--amber-light); color: #7a5200; }
.badge-muerto  { background: var(--red-light); color: var(--red); }
.badge-vaca    { background: #e8d5f5; color: #6b21a8; }
.badge-toro    { background: var(--sky-light); color: var(--sky); }
.badge-ternero { background: #fde9cc; color: #9a3412; }
.badge-info    { background: var(--sky-light); color: var(--sky); }

/* ── FILTERS ────────────────────────────────────────────── */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filter-select, .filter-input { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 13px; background: var(--bg); color: var(--text); font-family: var(--font); outline: none; }
.filter-input { flex: 1; min-width: 160px; }
.filter-select:focus, .filter-input:focus { border-color: var(--green-bright); }

/* ── TIMELINE ───────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: none; }
.timeline-dot { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; margin-top: 2px; }
.timeline-content { flex: 1; }
.timeline-title { font-weight: 500; font-size: 13.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.timeline-date { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.timeline-desc { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }

/* ── PROFILE ────────────────────────────────────────────── */
.animal-profile { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.profile-field { margin-bottom: 14px; }
.profile-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); margin-bottom: 3px; font-weight: 600; }
.profile-value { font-size: 14.5px; font-weight: 500; }
.profile-value a { color: var(--green-bright); text-decoration: none; }
.profile-value a:hover { text-decoration: underline; }
.age-pill { display: inline-block; background: var(--green-pale); color: var(--green-mid); border-radius: 100px; padding: 2px 10px; font-size: 12px; font-weight: 600; }

/* ── RECENT EVENTS ──────────────────────────────────────── */
.recent-event { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.recent-event:last-child { border-bottom: none; }
.event-icon { font-size: 20px; width: 32px; text-align: center; }
.event-info { flex: 1; }
.event-name { font-size: 13px; font-weight: 500; }
.event-detail { font-size: 12px; color: var(--text-muted); }
.event-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* ── TOAST ──────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--green-deep); color: white; padding: 12px 18px; border-radius: 10px; font-size: 13px; display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow-lg); animation: slideIn 0.3s ease; font-weight: 500; }
.toast.error { background: var(--red); }
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── MODAL ──────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.hidden { display: none; }
.modal { background: white; border-radius: 16px; padding: 28px; width: 100%; max-width: 520px; box-shadow: var(--shadow-lg); animation: modalIn 0.25s ease; max-height: 90vh; overflow-y: auto; }
@keyframes modalIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-weight: 700; font-size: 16px; letter-spacing: -0.3px; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--text-muted); padding: 4px; border-radius: 4px; }
.modal-close:hover { color: var(--red); }

/* ── EMPTY STATE ────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ── LLUVIA CHART ───────────────────────────────────────── */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding: 0 4px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar-wrap { width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; flex: 1; }
.bar { width: 100%; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, #4a8c3f, #2d5a27); transition: height 0.4s cubic-bezier(.4,0,.2,1); min-height: 2px; cursor: pointer; }
.bar:hover { filter: brightness(1.15); }
.bar-val { font-size: 10px; font-weight: 700; color: var(--green-mid); }
.bar-label { font-size: 10px; color: var(--text-muted); text-align: center; margin-top: 4px; }
.bar-zero { color: var(--border) !important; }

/* ── HELPERS ────────────────────────────────────────────── */
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.hidden { display: none !important; }
.action-link { color: var(--green-bright); cursor: pointer; font-size: 13px; text-decoration: none; font-weight: 500; }
.action-link:hover { text-decoration: underline; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ── WEIGHT CHART ───────────────────────────────────────── */
.weight-chart-wrap { overflow-x: auto; }
.weight-chart { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding: 0 4px; min-width: 300px; }
.weight-col { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; min-width: 44px; height: 100%; justify-content: flex-end; }
.weight-bar-wrap { width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; flex: 1; }
.weight-bar { width: 100%; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, var(--sky), #2a6080); min-height: 4px; transition: height 0.4s; }
.weight-val { font-size: 10px; font-weight: 700; color: var(--sky); }
.weight-label { font-size: 10px; color: var(--text-muted); text-align: center; }

/* ── CRIAS ──────────────────────────────────────────────── */
.crias-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 10px; }
.cria-card { background: var(--bg); border-radius: 10px; padding: 12px; border: 1px solid var(--border); text-decoration: none; color: var(--text); transition: box-shadow 0.2s, transform 0.2s; display: flex; align-items: center; gap: 10px; }
.cria-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.cria-icon { font-size: 26px; }
.cria-codigo { font-weight: 600; font-size: 13px; }
.cria-detail { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── CARAVANA HISTORIAL ─────────────────────────────────── */
.caravana-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.caravana-item:last-child { border-bottom: none; }
.caravana-codigo { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.caravana-activa { background: var(--green-pale); color: var(--green-mid); border-radius: 100px; padding: 2px 10px; font-size: 11px; font-weight: 600; }
.caravana-anterior { background: var(--amber-light); color: #7a5200; border-radius: 100px; padding: 2px 10px; font-size: 11px; font-weight: 600; }

/* ── FOTO ───────────────────────────────────────────────── */
.foto-animal { width:140px;height:140px;border-radius:16px;object-fit:cover;border:3px solid var(--green-pale);box-shadow:var(--shadow); }
.foto-placeholder { width:140px;height:140px;border-radius:16px;background:var(--bg);border:2px dashed var(--border);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;cursor:pointer;transition:border-color 0.2s; }
.foto-placeholder:hover { border-color:var(--green-bright); }
.foto-placeholder span { font-size:32px; }
.foto-placeholder p { font-size:11px;color:var(--text-muted);text-align:center;line-height:1.4; }
.foto-wrap { position:relative;display:inline-block; }
.foto-btn-change { position:absolute;bottom:6px;right:6px;background:var(--green-mid);color:white;border:none;border-radius:8px;padding:4px 8px;font-size:11px;cursor:pointer;opacity:0;transition:opacity 0.2s; }
.foto-wrap:hover .foto-btn-change { opacity:1; }

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-240px); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: block; }
  .content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .animal-profile { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr !important; }
}
