/* AGRICULTURAL ENGINEERING PORTAL - ULTRA-MODERN DESIGN SYSTEM */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  /* Color Palette - Luxury Deep Emerald & Electric Mint */
  --bg-app: #F3F7F4;
  --bg-surface: #FFFFFF;
  --bg-sidebar: linear-gradient(180deg, #061A11 0%, #0D2D1F 100%);

  --emerald-900: #061A11;
  --emerald-800: #0D2D1F;
  --emerald-700: #12402C;
  --emerald-600: #059669;
  --emerald-500: #10B981;
  --emerald-400: #34D399;
  --emerald-100: #D1FAE5;
  --emerald-50: #ECFDF5;

  --mint-glow: rgba(16, 185, 129, 0.25);

  --ink-900: #0F172A;
  --ink-700: #334155;
  --ink-500: #64748B;
  --ink-300: #94A3B8;
  --ink-100: #F1F5F9;

  --amber-500: #F59E0B;
  --amber-100: #FEF3C7;
  --rose-500: #EF4444;
  --rose-100: #FEE2E2;

  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 8px 16px -4px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --shadow-glow: 0 10px 25px -5px rgba(16, 185, 129, 0.35);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* CSS RESET & BASE STYLES */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--ink-900);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink-900);
}

a {
  color: var(--emerald-600);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--emerald-500);
}

/* APP LAYOUT */
.app-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* SIDEBAR */
.sidebar {
  width: 270px;
  background: var(--bg-sidebar);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
  transition: transform var(--transition-bounce), width var(--transition-normal);
}

.sidebar-header {
  padding: 1.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-badge {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--emerald-500), var(--emerald-700));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
}

.brand-badge img {
  width: 26px;
  height: 26px;
}

.brand-text h1 {
  color: #FFFFFF;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.brand-text span {
  font-size: 0.72rem;
  color: var(--emerald-400);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

/* SIDEBAR NAV */
.sidebar-nav {
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  overflow-y: auto;
}

.nav-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.4);
  font-weight: 700;
  margin: 1rem 0.75rem 0.35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.92rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  position: relative;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.75;
  transition: transform var(--transition-bounce), stroke var(--transition-fast);
}

.nav-item:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.06);
  transform: translateX(4px);
}

.nav-item:hover svg {
  stroke: var(--emerald-400);
  transform: scale(1.1);
}

.nav-item.active {
  color: #FFFFFF;
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.25) 0%, rgba(16, 185, 129, 0.05) 100%);
  border-left: 3.5px solid var(--emerald-400);
  font-weight: 600;
}

.nav-item.active svg {
  stroke: var(--emerald-400);
}

/* SIDEBAR FOOTER USER CARD */
.sidebar-user {
  padding: 1.25rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
  margin-top: auto;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--emerald-400), var(--emerald-600));
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-info h4 {
  color: #FFFFFF;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info span {
  font-size: 0.73rem;
  color: var(--emerald-400);
  text-transform: uppercase;
  font-weight: 600;
}

/* MAIN CONTENT CONTAINER */
.main-wrapper {
  flex: 1;
  margin-left: 270px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* TOP HEADER BAR */
.top-header {
  height: 72px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

.mobile-nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--ink-900);
}

.page-title h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--ink-900);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* MAIN CONTENT BODY */
.content-body {
  padding: 2rem;
  flex: 1;
  animation: fadeInUp 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* CARDS */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid #E2E8F0;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);

}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: #CBD5E1;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink-900);
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--emerald-600) 0%, var(--emerald-700) 100%);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--emerald-500) 0%, var(--emerald-600) 100%);
  color: #FFFFFF;
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #FFFFFF;
  color: var(--ink-700);
  border-color: #CBD5E1;
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--ink-100);
  color: var(--ink-900);
  border-color: var(--ink-300);
}

.btn-destructive {
  background: #FFFFFF;
  color: var(--rose-500);
  border-color: #FCA5A5;
}

.btn-destructive:hover {
  background: var(--rose-500);
  color: #FFFFFF;
  border-color: var(--rose-500);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-500);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: var(--ink-100);
  color: var(--ink-900);
  transform: scale(1.05);
}

.btn-icon.text-danger:hover {
  background: var(--rose-100);
  color: var(--rose-500);
}

/* FORM ELEMENTS */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--ink-700);
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.95rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--ink-900);
  background: #FFFFFF;
  border: 1.5px solid #CBD5E1;
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--transition-fast);
}

.form-control:focus {
  border-color: var(--emerald-500);
  box-shadow: 0 0 0 4px var(--mint-glow);
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row > .form-group {
  flex: 1;
}

/* TABLES */
.table-container {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid #E2E8F0;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.table th {
  background: #F8FAFC;
  padding: 1rem 1.25rem;
  font-weight: 700;
  color: var(--ink-700);
  text-transform: uppercase;
  font-size: 0.73rem;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #E2E8F0;
}

.table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #F1F5F9;
  color: var(--ink-900);
  vertical-align: middle;
}

.table tbody tr {
  transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
  background-color: #F8FAFC;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* STATUS PILLS */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
}

.status-pill.complete {
  background-color: var(--emerald-50);
  color: var(--emerald-600);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.status-pill.pending {
  background-color: var(--amber-100);
  color: var(--amber-500);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-pill.expired {
  background-color: var(--rose-100);
  color: var(--rose-500);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* TOAST FLASH MESSAGES */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--ink-900);
  color: #FFFFFF;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideInRight 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-success {
  border-left: 4px solid var(--emerald-400);
}

.toast-error {
  border-left: 4px solid var(--rose-500);
}

/* MODALS */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: scale(0.95);
  transition: transform var(--transition-bounce);
}

.modal-backdrop.active .modal-dialog {
  transform: scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #E2E8F0;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: #F8FAFC;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

/* PROGRAM CARDS & GRID (base) */
.program-card {
  border-left: 6px solid var(--emerald-600);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.program-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

/* ANIMATIONS */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* RESPONSIVENESS */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .mobile-nav-toggle {
    display: block;
  }
}

@media (max-width: 640px) {
  .top-header {
    padding: 0 1rem;
  }
  .content-body {
    padding: 1rem;
  }
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  .table-responsive-cards thead {
    display: none;
  }
  .table-responsive-cards tr {
    display: block;
    margin-bottom: 1rem;
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-radius: var(--radius-md);
    padding: 0.75rem;
  }
  .table-responsive-cards td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #F1F5F9;
    padding: 0.5rem 0;
  }
  .table-responsive-cards td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--ink-500);
    text-transform: uppercase;
  }
}

/* ============================================
   PROGRAM CARD REDESIGN — NEW ADDITIONS
   (thumbnail image, placeholder, badges, grid layout)
   These rules extend/override .program-card only for the
   redesigned Programs Directory cards — nothing above
   this point was changed.
   ============================================ */

.program-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 641px) {
  .program-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1100px) {
  .program-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Card container — overrides only padding/border of the base .program-card for this context */
.program-card {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-left: none;
  border-top: 4px solid var(--program-accent, var(--emerald-600));
}

.program-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* Thumbnail area */
.program-card-thumb {
  position: relative;
  width: 100%;
  height: 160px;
  background: var(--ink-100);
  overflow: hidden;
}

.program-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.program-card-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.25rem 1.25rem 1rem 1.25rem;
  color: #FFFFFF;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.program-card-thumb-placeholder::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.18) 0%, transparent 60%);
  pointer-events: none;
}

.program-card-placeholder-title {
  position: relative;
  z-index: 1;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.35;
  color: #FFFFFF;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.program-card-badges {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  right: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.program-year-pill {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(4px);
  border: none;
}

/* Card body */
.program-card-body {
  padding: 1.25rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.program-card-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ink-900);
  margin-bottom: 0.75rem;
}

.program-card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  margin-top: auto;
  border-top: 1px solid var(--ink-100);
}

/* Subtle accent tint on the primary button within a program card, using the program's own color */
.program-card .btn-primary {
  background: linear-gradient(135deg, var(--program-accent, var(--emerald-600)) 0%, var(--program-accent, var(--emerald-700)) 100%);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--program-accent, var(--emerald-600)) 35%, transparent);
}

/* Program Detail Responsive Views */
@media (max-width: 840px) {
  .program-detail-table-wrap {
    display: none !important;
  }
  .program-detail-card-stack {
    display: flex !important;
  }
}

/* SIDEBAR BACKDROP OVERLAY */
.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* ADVANCED MOBILE RESPONSIVENESS (<= 768px) */
@media (max-width: 768px) {
  .top-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    height: auto;
  }

  .top-header > div:first-child {
    justify-content: space-between;
    width: 100%;
  }

  .top-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
  }

  .top-actions .btn {
    flex: 1;
    justify-content: center;
    font-size: 0.85rem;
    padding: 0.55rem 0.85rem;
  }

  .content-body {
    padding: 0.85rem;
  }

  .card {
    padding: 1rem;
    border-radius: var(--radius-md);
  }

  .form-row {
    flex-direction: column;
    gap: 0.75rem;
  }

  .form-row > .form-group {
    width: 100% !important;
    flex: none !important;
  }

  /* Modals on Mobile */
  .modal-dialog,
  .modal-backdrop .card,
  .modal .card {
    width: 94% !important;
    max-width: 94% !important;
    margin: 1rem auto;
    padding: 1.25rem !important;
    max-height: 88vh !important;
    overflow-y: auto !important;
  }

  /* Repeaters (Equipment & Land Documents) */
  .equipment-row,
  .document-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem;
  }

  .equipment-row > div,
  .document-row > div {
    width: 100% !important;
  }

  /* Display fields & photo thumbnails */
  .display-field {
    font-size: 0.88rem;
    word-break: break-word;
    min-height: 38px;
    padding: 0.5rem 0.75rem;
  }

  .photo-thumbnail {
    width: 110px;
    height: 75px;
  }

  /* Tables container overflow */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* EXTRA SMALL MOBILE SCREENS (<= 480px) */
@media (max-width: 480px) {
  .page-title h2 {
    font-size: 1.15rem;
  }

  .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.82rem;
  }

  .photo-thumbnail {
    width: 95px;
    height: 65px;
  }

  .sidebar {
    width: 82vw;
  }
}