/* ============================================================
   app.css — Estilos del Sistema de Gestión Ganadera
   ============================================================ */

:root {
  --sidebar-width: 260px;
  --sidebar-bg:    #132b16;
  --sidebar-hover: #1e4421;
  --sidebar-active:#27ae60;
  --header-h:      70px;
  --primary:       #27ae60;
  --primary-dark:  #1e8449;
  --body-bg:       #f0f4f0;
  --card-shadow:   0 1px 4px rgba(0,0,0,.08);
}

/* ── Layout ─────────────────────────────────────────────────── */

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--body-bg);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

#sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 1000;
  transition: transform .25s ease;
}

#main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: calc(100vw - var(--sidebar-width));
}

/* ── Sidebar Brand ──────────────────────────────────────────── */

.sidebar-brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand i { font-size: 1.4rem; color: var(--primary); }

.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sidebar-brand-title { font-size: 1.05rem; font-weight: 700; letter-spacing: .3px; }
.sidebar-brand-empresa {
  font-size: .72rem;
  font-weight: 500;
  color: rgba(255,255,255,.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Sidebar Nav ────────────────────────────────────────────── */

.sidebar-nav {
  list-style: none;
  margin: 12px 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav .nav-item { margin: 2px 8px; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  color: #aacfb0;
  text-decoration: none;
  border-radius: 8px;
  font-size: .9rem;
  transition: background .15s, color .15s;
  cursor: pointer;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link[aria-expanded="true"] {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-nav .nav-link i:first-child { font-size: 1.05rem; width: 20px; text-align: center; }

.sidebar-nav .nav-item.active > .nav-link {
  background: var(--sidebar-active);
  color: #fff;
}

/* Subnav */
.nav-sub {
  list-style: none;
  padding: 4px 0 4px 44px;
  margin: 0;
}

.nav-sub li a {
  display: block;
  padding: 6px 10px;
  color: #8fbf96;
  text-decoration: none;
  font-size: .855rem;
  border-radius: 6px;
  transition: background .15s, color .15s;
}

.nav-sub li a:hover,
.nav-sub li a.active { background: var(--sidebar-hover); color: #fff; }

/* ── Sidebar Footer ─────────────────────────────────────────── */

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: .95rem;
  flex-shrink: 0;
}

.user-name { font-size: .82rem; color: #fff; font-weight: 600; line-height: 1.2; }
.user-role { font-size: .73rem; color: #6fa878; }

.btn-logout {
  margin-left: auto;
  color: #6fa878;
  font-size: 1.15rem;
  text-decoration: none;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}

.btn-logout:hover { background: rgba(255,255,255,.1); color: #e74c3c; }

/* ── Top Header ─────────────────────────────────────────────── */

.top-header {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid #e5ebe5;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

.breadcrumb-item + .breadcrumb-item::before { color: #aaa; }
.breadcrumb-item a { color: var(--primary); text-decoration: none; }
.breadcrumb-item.active { color: #555; }

/* ── Page Content ───────────────────────────────────────────── */

.page-content {
  padding: 24px;
  flex: 1;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1a3a1e;
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: .9rem;
  color: #6c757d;
  margin-bottom: 20px;
}

/* ── Cards ──────────────────────────────────────────────────── */

.card {
  border: 1px solid #e5ebe5;
  box-shadow: var(--card-shadow);
  border-radius: 10px;
}

.card-header {
  background: #fff;
  border-bottom: 1px solid #e5ebe5;
  font-weight: 600;
  padding: 14px 18px;
  border-radius: 10px 10px 0 0 !important;
}

/* ── Stat Cards ─────────────────────────────────────────────── */

.stat-card {
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: none;
  box-shadow: var(--card-shadow);
  transition: transform .15s, box-shadow .15s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.12); }

.stat-icon {
  width: 54px; height: 54px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .8rem; color: #6c757d; margin-top: 2px; }

/* ── Tabla DataTables ───────────────────────────────────────── */

.dataTables_wrapper .dataTables_filter input {
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 5px 10px;
}

.dataTables_wrapper .dataTables_length select {
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 4px 8px;
}

table.dataTable thead th { background: #f8faf8; font-weight: 600; font-size: .85rem; }
table.dataTable tbody tr:hover { background: #f0f8f0 !important; }
table.dataTable td { vertical-align: middle; font-size: .88rem; }

/* ── Badges personalizados ──────────────────────────────────── */

.bg-pink { background-color: #e91e8c !important; }
.bg-success-subtle { background-color: #d1f2dc !important; }

.badge { font-size: .73rem; font-weight: 600; letter-spacing: .3px; }

/* ── Ficha del animal ───────────────────────────────────────── */

.ficha-header {
  background: linear-gradient(135deg, #132b16 0%, #27ae60 100%);
  color: #fff;
  border-radius: 12px;
  padding: 24px 28px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.ficha-avatar {
  width: 70px; height: 70px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
}

.ficha-caravana { font-size: 1.8rem; font-weight: 800; letter-spacing: 1px; }
.ficha-nombre   { font-size: 1rem; opacity: .85; }
.ficha-meta     { font-size: .82rem; opacity: .7; margin-top: 4px; }

.ficha-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ── Tabs de ficha ──────────────────────────────────────────── */

.nav-tabs .nav-link { color: #555; font-size: .88rem; font-weight: 500; }
.nav-tabs .nav-link.active { color: var(--primary); font-weight: 600; }
.nav-tabs .nav-link:hover { color: var(--primary); }

/* ── Timeline de eventos ────────────────────────────────────── */

.event-timeline { position: relative; padding-left: 28px; }
.event-timeline::before {
  content: '';
  position: absolute;
  left: 8px; top: 0; bottom: 0;
  width: 2px;
  background: #dae8da;
}

.event-item {
  position: relative;
  padding: 10px 0 10px 16px;
  margin-bottom: 4px;
}

.event-item::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 18px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary);
}

.event-date  { font-size: .75rem; color: #888; }
.event-title { font-weight: 600; font-size: .9rem; }
.event-meta  { font-size: .8rem; color: #666; }

/* ── Formularios ────────────────────────────────────────────── */

.form-label { font-weight: 600; font-size: .85rem; color: #333; margin-bottom: 4px; }
.form-control, .form-select {
  border-color: #dde5dd;
  border-radius: 7px;
  font-size: .9rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 .2rem rgba(39,174,96,.2);
}

.section-divider {
  border-top: 1px solid #e5ebe5;
  margin: 24px 0 20px;
  padding-top: 20px;
}

.section-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 16px;
}

/* ── Botones ────────────────────────────────────────────────── */

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }

/* ── Login page ─────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0d1f0f 0%, #1a4a20 50%, #27ae60 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
}

.login-logo { font-size: 3rem; text-align: center; margin-bottom: 8px; }
.login-title { text-align: center; font-weight: 800; color: #1a3a1e; margin-bottom: 4px; }
.login-sub   { text-align: center; color: #6c757d; font-size: .88rem; margin-bottom: 28px; }

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 991px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #main-content { margin-left: 0; max-width: 100vw; }
}

/* ── Misc ───────────────────────────────────────────────────── */

.flash-container .alert { border-radius: 8px; font-size: .88rem; }

.text-primary { color: var(--primary) !important; }
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

.table-action-btn { font-size: .8rem; padding: 3px 8px; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #aaa;
}
.empty-state i { font-size: 3rem; display: block; margin-bottom: 12px; }
