/* assets/css/app.css - Dairy Cow Life Time Record Theme Styles */

/* ---------------- THEME VARIABLES ---------------- */
:root[data-bs-theme="light"] {
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;
  --text-main: #0f172a;
  --text-sub: #475569;
  --text-muted-custom: #94a3b8;
  --accent-color: #059669;
  --accent-hover: #047857;
  --accent-subtle: #ecfdf5;
  --hover-bg: #f1f5f9;
  --header-bg: rgba(255, 255, 255, 0.92);
  --preloader-bg: #ffffff;
  --tag-bg: #f1f5f9;
  --auth-glow: rgba(5, 150, 105, 0.08);
}

:root[data-bs-theme="dark"] {
  --bg-base: #090a0f;
  --bg-surface: #11131a;
  --bg-card: #151821;
  --border-color: #232736;
  --border-hover: #373e54;
  --text-main: #f1f5f9;
  --text-sub: #94a3b8;
  --text-muted-custom: #64748b;
  --accent-color: #10b981;
  --accent-hover: #059669;
  --accent-subtle: rgba(16, 185, 129, 0.12);
  --hover-bg: rgba(255, 255, 255, 0.04);
  --header-bg: rgba(17, 19, 26, 0.92);
  --preloader-bg: #090a0f;
  --tag-bg: #1c202c;
  --auth-glow: rgba(16, 185, 129, 0.12);
}

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --sidebar-w-collapsed: 58px;
  --sidebar-w-expanded: 230px;
  --topbar-h: 54px;
}

* {
  box-sizing: border-box;
  font-family: var(--font-sans);
  letter-spacing: -0.015em;
}

body {
  background-color: var(--bg-base);
  color: var(--text-main);
  font-size: 0.8rem;
  overflow-x: hidden;
  margin: 0;
  transition: background-color 0.2s ease, color 0.2s ease;
  min-height: 100vh;
}

/* ---------------- PRELOADER ---------------- */
#preloader {
  position: fixed;
  inset: 0;
  background: var(--preloader-bg);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#preloader.fade-out {
  opacity: 0;
  visibility: hidden;
}

.preloader-track {
  width: 130px;
  height: 3px;
  background: var(--border-color);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

.preloader-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 40%;
  background: var(--accent-color);
  animation: scan 1.1s infinite ease-in-out;
}

@keyframes scan {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ---------------- TOP LOADER BAR ---------------- */
#top-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--accent-color);
  box-shadow: 0 0 8px var(--accent-color);
  z-index: 10000;
  transition: width 0.22s ease-out, opacity 0.25s ease;
}

/* ---------------- BRAND & LOGO ---------------- */
.logo-node {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-color);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 32px;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25);
}

/* ---------------- FORM CONTROLS ---------------- */
.custom-input, .custom-select {
  background-color: var(--bg-surface) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-main) !important;
  font-size: 0.825rem;
  border-radius: 7px;
  padding: 8px 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.custom-input:focus, .custom-select:focus {
  border-color: var(--accent-color) !important;
  box-shadow: 0 0 0 3px var(--accent-subtle) !important;
  outline: none;
}

.input-group-text-custom {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted-custom);
  border-radius: 7px;
}

.form-check-input {
  background-color: var(--bg-surface);
  border-color: var(--border-color);
  cursor: pointer;
}

.form-check-input:checked {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
}

/* ---------------- BUTTONS ---------------- */
.btn-accent {
  background-color: var(--accent-color);
  color: #ffffff !important;
  border: none;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 7px;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.2);
}

.btn-accent:hover {
  background-color: var(--accent-hover);
  opacity: 0.95;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.28);
}

.btn-ghost {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.775rem;
  font-weight: 500;
  border-radius: 7px;
  padding: 7px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.12s ease;
}

.btn-ghost:hover {
  background: var(--hover-bg);
  border-color: var(--border-hover);
  color: var(--text-main);
}

.btn-action-icon {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-sub);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.12s ease;
  flex-shrink: 0;
}

.btn-action-icon:hover {
  background: var(--hover-bg);
  color: var(--text-main);
  border-color: var(--border-hover);
}

/* ---------------- THEME TOGGLE BUTTON ---------------- */
.theme-toggle-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-sub);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.theme-toggle-btn:hover {
  background: var(--hover-bg);
  color: var(--color-accent);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.theme-toggle-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}

.theme-toggle-btn i {
  font-size: 0.92rem;
  transition: transform 0.25s ease;
}

.theme-toggle-btn:hover i {
  transform: rotate(15deg);
}

/* ---------------- CARDS & AUTH ---------------- */
.card-custom {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  position: relative;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 2.25rem 2rem;
  box-shadow: 0 10px 30px var(--auth-glow), 0 1px 3px rgba(0, 0, 0, 0.05);
  position: relative;
  z-index: 2;
}

/* ---------------- BADGES & CHIPS ---------------- */
.badge-chip {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
  font-family: var(--font-mono);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-chip-soft-success {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

.badge-chip-soft-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
}

.badge-chip-soft-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

.badge-chip-soft-info {
  background: rgba(14, 165, 233, 0.12);
  color: #0284c7;
}

/* ---------------- SIDEBAR DOCK ---------------- */
.sidebar-dock {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--sidebar-w-collapsed);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  z-index: 1050;
  transition: width 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s ease;
  overflow-x: hidden;
  white-space: nowrap;
}

@media (min-width: 992px) {
  .sidebar-dock:hover {
    width: var(--sidebar-w-expanded);
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.06);
  }
  .sidebar-dock:hover .label-item,
  .sidebar-dock:hover .brand-text-label,
  .sidebar-dock:hover .badge-status {
    opacity: 1;
    transform: translateX(0);
  }
  .sidebar-dock:not(:hover) .cow-chip-expanded {
    display: none !important;
  }
  .sidebar-dock:not(:hover) .cow-chip-collapsed {
    display: flex !important;
  }
  .sidebar-dock:hover .cow-chip-collapsed {
    display: none !important;
  }
  .sidebar-dock:hover .cow-chip-expanded {
    display: block !important;
  }
}

/* ---------------- ACTIVE CATTLE SIDEBAR CHIP ---------------- */
.sidebar-cow-item {
  padding: 4px 6px;
  list-style: none;
}

.cow-chip-mini-badge {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--hover-bg);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  font-size: 1rem;
  color: var(--color-accent);
  transition: all 0.15s ease;
  cursor: pointer;
}

.cow-chip-mini-badge:hover {
  border-color: var(--color-accent);
  background: var(--accent-subtle);
}

.cow-chip-collapsed {
  display: none;
  align-items: center;
  justify-content: center;
}

@media (max-width: 991.98px) {
  .cow-chip-collapsed {
    display: none !important;
  }
  .cow-chip-expanded {
    display: block !important;
  }
}

.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 13px;
  border-bottom: 1px solid var(--border-color);
}

.brand-text-label {
  font-weight: 600;
  font-size: 0.85rem;
  margin-left: 10px;
  opacity: 0;
  transform: translateX(-4px);
  transition: all 0.18s ease;
  color: var(--text-main);
}

.nav-list {
  list-style: none;
  padding: 6px 8px;
  margin: 0;
}

.nav-node {
  display: flex;
  align-items: center;
  height: 38px;
  padding: 0 10px;
  border-radius: 7px;
  color: var(--text-sub);
  text-decoration: none;
  margin-bottom: 3px;
  transition: all 0.12s ease;
  cursor: pointer;
}

.nav-node i {
  font-size: 1.05rem;
  min-width: 22px;
  text-align: center;
}

.label-item {
  font-size: 0.775rem;
  font-weight: 500;
  margin-left: 11px;
  opacity: 0;
  transform: translateX(-4px);
  transition: all 0.18s ease;
}

.nav-node:hover {
  background: var(--hover-bg);
  color: var(--text-main);
}

.nav-node.active {
  background: var(--accent-subtle);
  color: var(--accent-color);
  font-weight: 600;
}

.badge-status {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: auto;
  background: var(--accent-subtle);
  color: var(--accent-color);
  opacity: 0;
  transition: opacity 0.15s ease;
}

/* Mobile drawer configuration */
@media (max-width: 991.98px) {
  .sidebar-dock {
    transform: translateX(-100%);
    width: 240px;
  }
  .sidebar-dock .label-item,
  .sidebar-dock .brand-text-label,
  .sidebar-dock .badge-status {
    opacity: 1;
    transform: none;
  }
  body.mobile-open .sidebar-dock {
    transform: translateX(0);
  }
  .mobile-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    z-index: 1045;
  }
  body.mobile-open .mobile-backdrop {
    display: block;
  }
}

/* ---------------- SIDEBAR SUB-MENU ---------------- */
.nav-sub-list {
  list-style: none;
  padding: 2px 0 4px 28px;
  margin: 0;
}

.nav-sub-node {
  display: flex;
  align-items: center;
  height: 30px;
  padding: 0 9px;
  border-radius: 6px;
  color: var(--text-sub);
  text-decoration: none;
  font-size: 0.725rem;
  margin-bottom: 2px;
  transition: all 0.12s ease;
  cursor: pointer;
}

.nav-sub-node:hover {
  background: var(--hover-bg);
  color: var(--text-main);
}

.nav-sub-node.active {
  color: var(--accent-color);
  font-weight: 600;
  background: var(--accent-subtle);
}

.nav-sub-node::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 8px;
  opacity: 0.6;
}

.chevron-arrow {
  margin-left: auto;
  font-size: 0.75rem;
  transition: transform 0.2s ease;
  opacity: 0;
}

.sidebar-dock:hover .chevron-arrow,
body.mobile-open .sidebar-dock .chevron-arrow {
  opacity: 1;
}

.nav-node[aria-expanded="true"] .chevron-arrow {
  transform: rotate(180deg);
}

/* Hide sub-menus when collapsed desktop sidebar */
@media (min-width: 992px) {
  .sidebar-dock:not(:hover) .nav-sub-list {
    display: none !important;
  }
}

/* ---------------- APP SHELL ---------------- */
.app-viewport {
  margin-left: var(--sidebar-w-collapsed);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

@media (max-width: 991.98px) {
  .app-viewport { margin-left: 0; }
}

.top-header {
  height: var(--topbar-h);
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
}

/* ---------------- METRIC CARD ---------------- */
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  position: relative;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.metric-card:hover {
  border-color: var(--border-hover);
}

.metric-title {
  font-size: 0.675rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted-custom);
}

.metric-number {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.02em;
  font-family: var(--font-mono);
  margin: 4px 0 2px 0;
}

.metric-subtext {
  font-size: 0.675rem;
  color: var(--text-muted-custom);
}

/* ---------------- DEMO CREDENTIALS BOX ---------------- */
.demo-creds-box {
  background: var(--hover-bg);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  margin-top: 1.25rem;
}

.demo-account-pill {
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
  transition: all 0.12s ease;
  font-size: 0.72rem;
}

.demo-account-pill:hover {
  border-color: var(--accent-color);
  background: var(--accent-subtle);
}

/* ---------------- OFFCANVAS & MODAL ---------------- */
.offcanvas,
.offcanvas-custom {
  background-color: var(--bg-surface) !important;
  color: var(--text-main) !important;
  border-left: 1px solid var(--border-color) !important;
  max-width: 92vw;
  width: 480px !important;
  display: flex !important;
  flex-direction: column !important;
  height: 100vh !important;
  max-height: 100vh !important;
  overflow: hidden !important;
}

.offcanvas-custom form,
.offcanvas form {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: 100% !important;
  max-height: 100% !important;
  overflow: hidden !important;
}

.panel-header-custom,
.offcanvas-header {
  flex-shrink: 0 !important;
  border-bottom: 1px solid var(--border-color) !important;
  padding: 0.9rem 1.25rem !important;
  background: var(--bg-surface) !important;
}

.offcanvas-body {
  flex: 1 1 auto !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  min-height: 0 !important;
  padding: 1.15rem 1.25rem !important;
  -webkit-overflow-scrolling: touch;
}

.panel-footer-custom,
.offcanvas-footer {
  flex-shrink: 0 !important;
  border-top: 1px solid var(--border-color) !important;
  padding: 0.85rem 1.25rem !important;
  background: var(--bg-surface) !important;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.03);
}

/* Custom sleek scrollbar for offcanvas and table containers */
.offcanvas-body::-webkit-scrollbar,
.custom-scroll::-webkit-scrollbar {
  width: 6px;
}
.offcanvas-body::-webkit-scrollbar-track,
.custom-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.offcanvas-body::-webkit-scrollbar-thumb,
.custom-scroll::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 99px;
}
.offcanvas-body::-webkit-scrollbar-thumb:hover,
.custom-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* ---------------- COLOR & EMERALD CHIP UTILITIES ---------------- */
.text-emerald {
  color: var(--accent-color) !important;
}
.bg-emerald-subtle {
  background-color: var(--accent-subtle) !important;
}
.border-emerald-subtle {
  border-color: rgba(16, 185, 129, 0.25) !important;
}

.modal-content-custom {
  background-color: var(--bg-card) !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 12px;
}

/* ---------------- GRID MEDIA CARDS (CATTLE) ---------------- */
.resource-card, .cattle-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  position: relative;
}

.resource-card:hover, .cattle-card:hover {
  border-color: var(--accent-color);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
}

.resource-img-wrap, .cattle-img-wrap {
  height: 165px;
  width: 100%;
  position: relative;
  background: var(--hover-bg);
  overflow: hidden;
}

.resource-img-wrap img, .cattle-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.resource-card:hover .resource-img-wrap img,
.cattle-card:hover .cattle-img-wrap img {
  transform: scale(1.03);
}

.cattle-placeholder-img {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--hover-bg), var(--border-color));
  color: var(--text-muted-custom);
}
