/* ==========================================================================
   Jaguza Farm — custom admin theme
   Layered on top of Bootstrap 4 (css/app.css). Provides the app shell
   (sidebar/header/footer), card/table/form/modal polish, and responsive
   behavior for the dashboard.
   ========================================================================== */

:root {
  --jf-bg: #f4f6f9;
  --jf-surface: #ffffff;
  --jf-border: #e5e9f0;
  --jf-text: #2f3542;
  --jf-text-muted: #7b8597;
  --jf-primary: #3490dc;
  --jf-primary-dark: #2672b3;
  --jf-sidebar-bg: #1f2635;
  --jf-sidebar-bg-active: #2a3246;
  --jf-sidebar-text: #aeb6c6;
  --jf-sidebar-text-active: #ffffff;
  --jf-header-h: 64px;
  --jf-sidebar-w: 260px;
  --jf-radius: 10px;
  --jf-shadow: 0 2px 10px rgba(31, 38, 53, 0.06);
  --jf-shadow-lg: 0 8px 24px rgba(31, 38, 53, 0.10);
}

* { box-sizing: border-box; }

html, body {
  background: var(--jf-bg);
  color: var(--jf-text);
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

a { color: var(--jf-primary); }
a:hover { color: var(--jf-primary-dark); }

/* ---------------------------------------------------------------------- */
/* App shell                                                               */
/* ---------------------------------------------------------------------- */

.app-container { min-height: 100vh; }

.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--jf-header-h);
  display: flex;
  align-items: center;
  background: var(--jf-surface);
  border-bottom: 1px solid var(--jf-border);
  z-index: 1030;
  padding: 0 1rem;
}

.app-header__logo {
  width: var(--jf-sidebar-w);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  flex-shrink: 0;
}

.app-header__logo .logo-src {
  width: 36px; height: 36px;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--jf-border);
}

.app-header__logo .logo-src img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.app-header__logo-text {
  margin-left: 0.6rem;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--jf-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header__mobile-menu,
.app-header__menu { display: none; }

.app-header__content {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

.header-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  background: var(--jf-primary);
  color: #fff;
  font-weight: 800;
}

.profile-trigger {
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
  padding: 0.3rem 0.5rem;
  transition: background 0.15s ease;
}

.profile-trigger:hover { background: var(--jf-bg); }
.profile-trigger .widget-content-wrapper { display: flex; align-items: center; }

.profile-modal-avatar { width: 64px; height: 64px; font-size: 1.5rem; }

.app-header-right .widget-heading { font-weight: 700; font-size: 0.9rem; }
.app-header-right .widget-subheading { color: var(--jf-text-muted); font-size: 0.78rem; }

.hamburger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
}

.hamburger:hover { background: var(--jf-bg); }

.hamburger-box {
  position: relative;
  display: inline-block;
  width: 20px;
  height: 14px;
}

.hamburger-inner,
.hamburger-inner::before,
.hamburger-inner::after {
  position: absolute;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: var(--jf-text);
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.hamburger-inner { top: 6px; }
.hamburger-inner::before { content: ""; top: -6px; }
.hamburger-inner::after { content: ""; top: 6px; }

.header__pane { display: flex; align-items: center; }

.app-main {
  display: flex;
  padding-top: var(--jf-header-h);
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  position: fixed;
  top: var(--jf-header-h);
  left: 0; bottom: 0;
  width: var(--jf-sidebar-w);
  background: var(--jf-sidebar-bg);
  overflow-y: auto;
  z-index: 1020;
  transition: transform 0.2s ease;
}

.app-sidebar .app-header__logo,
.app-sidebar .app-header__mobile-menu,
.app-sidebar .app-header__menu { display: none; }

.scrollbar-sidebar, .app-sidebar__inner {
  height: auto !important;
  overflow: visible !important;
}

.vertical-nav-menu { list-style: none; margin: 0; padding: 0.75rem 0; }

.app-sidebar__heading {
  padding: 1rem 1.25rem 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #5d6578;
  font-weight: 700;
}

.vertical-nav-menu li a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 1.25rem;
  color: var(--jf-sidebar-text);
  font-size: 0.88rem;
  font-weight: 600;
  border-left: 3px solid transparent;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.vertical-nav-menu li a:hover {
  background: var(--jf-sidebar-bg-active);
  color: var(--jf-sidebar-text-active);
  text-decoration: none;
}

.vertical-nav-menu li a.active {
  background: var(--jf-sidebar-bg-active);
  color: var(--jf-sidebar-text-active);
  border-left-color: var(--jf-primary);
}

.vertical-nav-menu .metismenu-icon {
  font-size: 1.05rem;
  width: 1.3rem;
  text-align: center;
  flex-shrink: 0;
}

/* Main content column */
.app-main__outer {
  flex: 1;
  margin-left: var(--jf-sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-main__inner {
  flex: 1;
  padding: 1.5rem;
  max-width: 100%;
}

/* Page title */
.app-page-title { margin-bottom: 1.25rem; }

.page-title-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  background: var(--jf-surface);
  border: 1px solid var(--jf-border);
  border-radius: var(--jf-radius);
  padding: 1.1rem 1.4rem;
  box-shadow: var(--jf-shadow);
}

.page-title-heading { display: flex; align-items: center; gap: 1rem; font-size: 1.25rem; font-weight: 800; }

.page-title-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--jf-primary), #6cb2eb);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.2rem; flex-shrink: 0;
}

.page-title-subheading { font-size: 0.85rem; font-weight: 500; color: var(--jf-text-muted); margin-top: 0.15rem; }

.page-title-actions { display: flex; align-items: center; gap: 0.5rem; }

/* Footer */
.app-wrapper-footer { margin-left: var(--jf-sidebar-w); }

.app-footer__inner {
  display: flex;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  color: var(--jf-text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--jf-border);
}

.app-footer .nav-link { color: var(--jf-text-muted); padding: 0.25rem 0.5rem; }

/* ---------------------------------------------------------------------- */
/* Cards                                                                   */
/* ---------------------------------------------------------------------- */

.card, .main-card {
  border: 1px solid var(--jf-border);
  border-radius: var(--jf-radius);
  box-shadow: var(--jf-shadow);
}

.card-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 1rem; }

.card-body { padding: 1.25rem 1.4rem; }

/* ---------------------------------------------------------------------- */
/* Tables                                                                  */
/* ---------------------------------------------------------------------- */

.table { margin-bottom: 0; }

.table thead th {
  border-top: none;
  border-bottom: 1px solid var(--jf-border);
  background: #f9fafc;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--jf-text-muted);
  font-weight: 700;
  white-space: nowrap;
}

.table td { vertical-align: middle; font-size: 0.88rem; }

.table-hover tbody tr:hover { background-color: #f6f9fd; }

.table-responsive { border-radius: var(--jf-radius); }

.text-truncate-cell {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------------------------------------------------------------- */
/* Buttons & forms                                                         */
/* ---------------------------------------------------------------------- */

.btn {
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
}

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

.form-control, .custom-select {
  border-radius: 8px;
  border-color: var(--jf-border);
  font-size: 0.88rem;
}

.form-control:focus {
  border-color: var(--jf-primary);
  box-shadow: 0 0 0 0.15rem rgba(52, 144, 220, 0.15);
}

label { font-weight: 600; font-size: 0.85rem; color: var(--jf-text); }

/* ---------------------------------------------------------------------- */
/* Modals                                                                  */
/* ---------------------------------------------------------------------- */

.modal-content { border: none; border-radius: var(--jf-radius); box-shadow: var(--jf-shadow-lg); }
.modal-header { border-bottom: 1px solid var(--jf-border); }
.modal-footer { border-top: 1px solid var(--jf-border); }

#rowDetailModalBody dt { color: var(--jf-text-muted); font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
#rowDetailModalBody dd { font-size: 0.9rem; margin-bottom: 0.75rem; }

.row-actions { display: flex; align-items: center; gap: 0.4rem; white-space: nowrap; }

.btn-icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 7px;
  border: 1px solid var(--jf-border);
  background: var(--jf-surface);
  color: var(--jf-text-muted);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-icon-action:hover { text-decoration: none; }
.btn-icon-action.view-action:hover { color: #fff; background: var(--jf-primary); border-color: var(--jf-primary); }
.btn-icon-action.edit-action:hover { color: #fff; background: var(--jf-orange, #f6993f); border-color: var(--jf-orange, #f6993f); }
.btn-icon-action.delete-action:hover { color: #fff; background: #e3342f; border-color: #e3342f; }

/* ---------------------------------------------------------------------- */
/* Dashboard charts                                                        */
/* ---------------------------------------------------------------------- */

.viz-root {
  --chart-ink-primary: #0b0b0b;
  --chart-ink-secondary: #52514e;
  --chart-ink-muted: #898781;
  --chart-gridline: #e1e0d9;
  --chart-series-1: #2a78d6;
  --chart-series-1-wash: rgba(42, 120, 214, 0.1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .viz-root {
    --chart-ink-primary: #ffffff;
    --chart-ink-secondary: #c3c2b7;
    --chart-ink-muted: #898781;
    --chart-gridline: #2c2c2a;
    --chart-series-1: #3987e5;
    --chart-series-1-wash: rgba(57, 135, 229, 0.14);
  }
}

.chart-line { width: 100%; height: 160px; overflow: visible; }
.chart-area { fill: var(--chart-series-1-wash); stroke: none; }
.chart-line-stroke { fill: none; stroke: var(--chart-series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--chart-series-1); stroke: var(--jf-surface); stroke-width: 2; }

.chart-x-labels {
  display: flex;
  justify-content: space-between;
  padding: 0 20px;
  margin-top: 0.25rem;
  color: var(--chart-ink-muted);
  font-size: 0.72rem;
}

/* Vertical bar columns (animals by type) */
.bar-chart-columns {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 1rem;
  height: 180px;
  padding-top: 1.5rem;
}

.bar-col { display: flex; flex-direction: column; align-items: center; flex: 1; height: 100%; }

.bar-col-track {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  position: relative;
}

.bar-col-fill {
  width: 100%;
  max-width: 48px;
  background: var(--jf-primary);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height 0.2s ease;
}

.bar-col-value {
  position: absolute;
  top: -1.4rem;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--jf-text);
}

.bar-col-label {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: var(--jf-text-muted);
  font-weight: 600;
  text-align: center;
}

/* Horizontal bars (top farms) */
.hbar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.hbar-label { width: 35%; font-size: 0.85rem; font-weight: 600; max-width: none; }

.hbar-track {
  flex: 1;
  background: var(--jf-bg);
  border-radius: 6px;
  height: 14px;
  overflow: hidden;
}

.hbar-fill {
  height: 100%;
  background: var(--jf-primary);
  border-radius: 6px;
  min-width: 4px;
  transition: width 0.2s ease;
}

.hbar-value { width: 40px; text-align: right; font-weight: 700; font-size: 0.85rem; }

/* ---------------------------------------------------------------------- */
/* Dashboard stat cards & quick links                                      */
/* ---------------------------------------------------------------------- */

.stat-card-body {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-card-icon {
  width: 52px;
  height: 52px;
  min-width: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.4rem;
}

.stat-card-icon.bg-primary { background: var(--jf-primary); }
.stat-card-icon.bg-success { background: var(--green, #38c172); }
.stat-card-icon.bg-warning { background: var(--orange, #f6993f); }
.stat-card-icon.bg-info { background: var(--cyan, #6cb2eb); }

.stat-card-value {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
}

.stat-card-label {
  color: var(--jf-text-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.quick-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 0.5rem;
  border: 1px solid var(--jf-border);
  border-radius: var(--jf-radius);
  color: var(--jf-text);
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.quick-link i { font-size: 1.5rem; color: var(--jf-primary); }

.quick-link:hover {
  background: var(--jf-primary);
  border-color: var(--jf-primary);
  color: #fff;
  text-decoration: none;
}

.quick-link:hover i { color: #fff; }

/* ---------------------------------------------------------------------- */
/* Badges                                                                  */
/* ---------------------------------------------------------------------- */

.badge { font-weight: 700; border-radius: 6px; }

/* ---------------------------------------------------------------------- */
/* Collapsed sidebar (icon-only, desktop)                                  */
/* ---------------------------------------------------------------------- */

@media (min-width: 992px) {
  .app-container.closed-sidebar { --jf-sidebar-w: 70px; }

  .app-container.closed-sidebar .app-header__logo-text,
  .app-container.closed-sidebar .app-sidebar__heading,
  .app-container.closed-sidebar .vertical-nav-menu li a .nav-label {
    display: none;
  }

  .app-container.closed-sidebar .vertical-nav-menu li a {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  .app-container.closed-sidebar .metismenu-icon {
    font-size: 1.25rem;
  }
}

/* ---------------------------------------------------------------------- */
/* Auth pages (login / register / password reset)                         */
/* ---------------------------------------------------------------------- */

.auth-body {
  background: linear-gradient(135deg, var(--jf-sidebar-bg), #2a3a52 60%, var(--jf-primary));
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-wrapper {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.auth-card {
  width: 100%;
  background: var(--jf-surface);
  border-radius: 14px;
  box-shadow: var(--jf-shadow-lg);
  padding: 2.25rem 2rem;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1.5rem;
}

.auth-brand img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--jf-border);
  background: #fff;
  padding: 6px;
}

.auth-brand-name {
  margin-top: 0.6rem;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--jf-text);
}

.auth-title {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.auth-subtitle {
  text-align: center;
  color: var(--jf-text-muted);
  font-size: 0.88rem;
  margin-bottom: 1.5rem;
}

.auth-form .form-group { margin-bottom: 1.1rem; }

.auth-form label {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--jf-text-muted);
  margin-bottom: 0.35rem;
}

.auth-form .form-control {
  padding: 0.6rem 0.85rem;
  height: auto;
}

.auth-form .btn-block { padding: 0.65rem; font-size: 0.9rem; }

.auth-links {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.85rem;
}

.auth-links a { color: var(--jf-primary); font-weight: 600; }

.auth-footer {
  margin-top: 1.5rem;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.78rem;
  text-align: center;
}

/* ---------------------------------------------------------------------- */
/* Responsive                                                              */
/* ---------------------------------------------------------------------- */

@media (max-width: 991.98px) {
  .app-header__logo { width: auto; }
  .app-header__logo-text { display: none; }
  .app-header__mobile-menu { display: flex; align-items: center; }
  .app-header__menu { display: flex; align-items: center; margin-left: auto; margin-right: 0.5rem; }

  .app-sidebar {
    transform: translateX(-100%);
    box-shadow: var(--jf-shadow-lg);
  }
  .app-container.closed-sidebar .app-sidebar { transform: translateX(0); }

  .app-main__outer,
  .app-wrapper-footer { margin-left: 0; }

  .app-main__inner { padding: 1rem; }

  .page-title-wrapper { padding: 0.9rem 1rem; }
  .page-title-heading { font-size: 1.05rem; }
}

@media (max-width: 575.98px) {
  .page-title-icon { width: 38px; height: 38px; font-size: 1rem; }
  .page-title-actions { width: 100%; justify-content: flex-start; }
  .card-body { padding: 1rem; }
}
