*, *::before, *::after {
  box-sizing: border-box;
}

/* Body Setup */
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch; /* Fixed: Allows full-width elements like footer & header to span 100% */
  min-height: 100vh;
  font-family: 'Bespoke Sans', sans-serif;
  color: #28089a;
  background-image: linear-gradient(to right, #a1bde7, #4b80c6, #ffffff);  
  background-color: #fff;
}

/* Header Container */
.site-header {
  display: flex;
  flex-direction: column;
  width: 100%; /* Ensures header spans full browser width */
  background-image: linear-gradient(to right, #043b8f, #0a4b9e);
  color: #ffffff;
  font-style: italic;
  font-weight: bold;
}

/* Top Branding Area */
.header-content {
  padding: 12px 24px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px 20px;
}

/* Logo Sizing */
.logo-container {
  width: 140px;
  grid-row: 1 / span 2;
  align-self: start;
  flex-shrink: 0;
}

.scaled-svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Typography Layout */
h1 {
  font-size: 2.1rem;
  margin: 0;
  text-align: left;
  line-height: 1.1;
}

.break-row {
  margin: 0;
  text-align: left;
  font-size: 1.1rem;
  font-weight: 400;
  opacity: 0.9;
}

/* Button-Style Navigation */
.navbar {
  margin-top: 5px;
  background-color: rgba(0, 0, 0, 0.15);
  padding: 4px 24px;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0;
  padding: 0;
}

.nav-links li {
  position: relative;
}

/* Button Base */
.nav-links a {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  color: #e5e7eb;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 6px;
  background-color: transparent;
  transition: all 0.2s ease-in-out;
}

/* Hover State - Colored Highlight Button */
.nav-links a:hover {
  background-color: #2563eb; /* Vibrant Blue */
  color: #ffffff;
  text-decoration: none;
}

/* Active Page Button */
.nav-links a.active {
  background-color: #0d9488; /* Teal Highlight for Current Page */
  color: #ffffff;
}

/* Active Page Button Hover State */
.nav-links a.active:hover {
  background-color: #0f766e;
  color: #ffffff;
}

/* Dropdown Menu Styling */
.dropdown:hover .submenu {
  display: block;
}

.submenu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background-color: #ffffff;
  min-width: 160px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  padding: 0.5rem 0;
  z-index: 100;
  list-style: none;
}

.submenu li a {
  color: #374151;
  display: block;
  padding: 0.5rem 1rem;
  border-radius: 0;
}

/* Smooth background highlight on submenu item hover */
.nav-links .submenu a:hover {
  background-color: #090d98;
  color: #ff8400;
}

/* Triggers the dropdown visibility on hover */
.nav-links .dropdown:hover .submenu {
  display: block;
}

/* --- MOBILE RESPONSIVENESS REFINEMENTS --- */
@media (max-width: 768px) {
  .header-content {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    padding: 16px 15px;
    gap: 10px;
  }

  .logo-container {
    grid-row: auto;
    align-self: center;
    width: 120px;
  }

  h1 {
    font-size: 1.6rem;
    text-align: center;
  }

  .break-row {
    font-size: 1rem;
    text-align: center;
  }

  .nav-links {
    justify-content: center;
    flex-wrap: wrap;
  }
}

.hidden { 
  display: none; 
}

/* Field Group Setup */
.field-group {
  display: grid;
  grid-column: span var(--colspan);
  grid-row: span var(--rowspan, 1);
  inline-size: 100%;
  gap: .5rem; 
}

.selContact {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  justify-items: left;
  gap: 1rem;
  margin: 1rem;
  padding: 10px;
}

.selBox {
  background-color: rgb(29, 5, 151);
}

.nbtn {
  width: 150px;
  height: 30px;
  background-color: rgb(29, 5, 151);
  font-weight: bold;
  color: #ffffff;
  align-self: baseline;
}

.nborder {
  border: none;
}

form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 1000px;
  padding: 2rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  box-sizing: border-box;
}

/* Small inline forms (e.g. a single "Delete" button next to other action
   buttons/links in a table row) must not inherit the block-form styling
   above, otherwise the padded/shadowed white box overlaps neighboring
   buttons. */
form.inline-form {
  display: inline;
  width: auto;
  max-width: none;
  padding: 0;
  background: none;
  border-radius: 0;
  box-shadow: none;
}

/* Base Grid Section Elements */
.form-grid-section-8 {
  display: grid;
  grid-template-columns: repeat(8, 1fr); 
  gap: .5rem;
  width: 100%;
}

.form-grid-section-9 {
  display: grid;
  grid-template-columns: repeat(9, 1fr); 
  gap: .5rem;
  width: 100%;
}

.form-grid-section-12 {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: .5rem;
  width: 100%;
}

.form-grid-section-short {
  display: grid;
  grid-template-columns: repeat(6, 1fr); 
  gap: 2rem;
  width: 60%;
  margin-right: auto;
}

.form-grid-section-70 {
  display: grid;
  grid-template-columns: repeat(8, 1fr); 
  gap: 1rem;
  width: 70%;
  margin-right: auto;
}

.form-grid-section-short-40 {
  display: grid;
  grid-template-columns: repeat(4, 1fr); 
  gap: 2rem;
  width: 40%;
  margin-right: auto;
}

.form-grid-section-short-rght {
  display: grid;
  grid-template-columns: repeat(6, 1fr); 
  gap: .5rem;
  width: 40%;
  margin-left: auto;
}

.gcol {
  grid-column: span var(--colspan);
}

.grow {
  grid-row: span var(--rowspan);
}

/* Ministry Two-Column Grid System Design */
#ministry-section {
  width: 100%;
  display: none;
}

#checkbox-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px 30px;
  width: 100%;
}

.ministry-card select {
  width: 100%;
  max-width: 240px;
  height: 32px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  background-color: #ffffff;
  color: #28089a;
  padding: 0 5px;
}

/* Text validation styles */
.text-danger {
  color: #dc2626 !important;
  font-size: 0.85rem;
  margin-top: 2px;
  display: block;
}

/* Button UI Components */
.btn-primary {
  background-color: #4f46e5;
  color: #ffffff;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.btn-primary:hover {
  background-color: #3c2de4;
}

.btn-primary:active {
  transform: scale(0.96);
}

.btn-danger {
  background-color: #dc2626;
  color: #ffffff;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.btn-danger:hover {
  background-color: #b91c1c;
}

.btn-danger:active {
  transform: scale(0.96);
}

.btn-pulse {
  background-color: #0ea5e9;
  color: #ffffff;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.1s ease;
}

.btn-pulse:hover {
  background-color: #0284c7;
}

.btn-pulse:active {
  transform: scale(0.97);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.25);
}

.btn-secondary {
  background-color: #64748b;
  color: #ffffff;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

/* Spinner styles */
.spinner {
  display: none;
  width: 12px;
  height: 12px;
  margin-left: 5px;
  vertical-align: middle;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  100% { transform: rotate(360deg); }
}

/* State when button is processing */
.delete-btn.loading {
  opacity: 0.6;
  cursor: not-allowed;
}

.delete-btn.loading .spinner {
  display: inline-block;
}

/* Responsive Form Breakpoints */
@media screen and (max-width: 768px) {
  form {
    padding: 1rem;
  }
  
  .form-grid-section-8,
  .form-grid-section-9,
  .form-grid-section-12,
  #checkbox-container {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  .form-grid-section-short,
  .form-grid-section-short-rght {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .selContact {
    grid-template-columns: 1fr;
  }
  
  .ministry-card select {
    max-width: 100%;
  }
}

/* Dashboard Layout & Widget Styles */
.dashboard-container {
  width: 100%;
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  box-sizing: border-box;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: #ffffff;
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-left: 5px solid #2563eb;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.kpi-card.highlight {
  border-left-color: #0d9488;
  background: linear-gradient(135deg, #ffffff 0%, #f0fdfa 100%);
}

.kpi-title {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.kpi-value {
  font-size: 2.25rem;
  font-weight: 800;
  color: #28089a;
  line-height: 1.1;
  margin-bottom: 0.35rem;
}

.kpi-subtext {
  font-size: 0.8rem;
  color: #64748b;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.75rem;
  align-items: start;
}

.dashboard-main-grid {
  display: grid;
  /* Automatically fits items with a minimum width of 250px */
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.25rem;
}

.main-content,
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.card {
  background: #ffffff;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.card h3 {
  margin-top: 0;
  margin-bottom: 1.25rem;
  color: #28089a;
  font-size: 1.25rem;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 0.5rem;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.action-buttons .btn {
  display: inline-block;
  text-decoration: none;
  text-align: center;
  line-height: 1.2;
}

.btn-accent {
  background-color: #0d9488;
  color: #ffffff;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-accent:hover {
  background-color: #0f766e;
}

/* Smaller variant for action buttons (e.g. table row "View"/"Delete"
   buttons). Applied alongside a color modifier, e.g. "btn btn-sm btn-primary".
   Declared last so its reduced padding/font-size take precedence over the
   color modifier rules above. */
.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  text-align: left;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.925rem;
}

.data-table th {
  background-color: #f8fafc;
  color: #28089a;
  font-weight: 700;
}

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

.quick-links,
.task-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.task-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px dashed #e2e8f0;
}

.task-list li:last-child {
  border-bottom: none;
}

.task-list input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #4f46e5;
  cursor: pointer;
}

.task-list label {
  font-size: 0.9rem;
  color: #334155;
  cursor: pointer;
}

.link-btn {
  display: inline-block;
  color: #4f46e5;
  font-weight: 600;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s ease;
}

.link-btn:hover {
  color: #2563eb;
  text-decoration: underline;
}

/* Dashboard Breakpoints */
@media screen and (max-width: 900px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }
}

@media screen and (max-width: 600px) {
  .data-table th, 
  .data-table td {
    padding: 0.5rem;
    font-size: 0.85rem;
  }
  
  .action-buttons .btn {
    width: 100%;
  }
}

.dateTimeContainer{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

/* --- MULTI-LEVEL NAVIGATION DROPDOWNS --- */
.navbar ul.nav-links li {
  position: relative;
}

/* Primary Submenu (Drops Down) */
.navbar ul.submenu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background-color: #175bbb; /* Dark slate background matching navbar theme */
  min-width: 210px;
  padding: 8px 0;
  margin: 0;
  list-style: none;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
  z-index: 1000;
}

.navbar ul.submenu li {
  width: 100%;
  position: relative;
}

.navbar ul.submenu li a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  color: #f8fafc;
  font-size: 0.92rem;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}

.navbar ul.submenu li a:hover {
  background-color: #232b78;
  color: #f59e0b; /* Accent highlight color */
}

/* Show Submenu on Parent Hover */
.navbar ul.nav-links li.dropdown:hover > .submenu {
  display: block;
}

/* Secondary Nested Submenu (Fly-Out Right) */
.navbar ul.submenu li.dropdown-submenu > .submenu {
  top: 0;
  left: 100%;
  border-radius: 0 6px 6px 6px;
  box-shadow: 4px 8px 16px rgba(0, 0, 0, 0.25);
}

.navbar ul.submenu li.dropdown-submenu:hover > .submenu {
  display: block;
}

/* Submenu Arrow Indicator */
.navbar ul.submenu li.dropdown-submenu a .arrow {
  font-size: 0.85rem;
  margin-left: 10px;
  color: #94a3b8;
}

.navbar ul.submenu li.dropdown-submenu:hover > a .arrow {
  color: #f59e0b;
}

/* --- SITE FOOTER STYLES --- */
.site-footer {
  width: 100%;
  flex-shrink: 0; /* Fixed: Prevents footer compression on low height viewports */
  background-image: linear-gradient(to right, #043b8f, #0a4b9e);
  color: #ffffff;
  margin-top: auto; /* Ensures footer stays at the bottom on short pages */
  font-family: inherit;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 1.5rem 2rem 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 2.5rem 1.5rem;
}

/* Brand Section */
.footer-brand .footer-logo {
  width: 60px;
  margin-bottom: 0.75rem;
}

.footer-brand h3 {
  font-size: 1.15rem;
  margin: 0 0 0.5rem 0;
  font-weight: 700;
  color: #ffffff;
}

.footer-desc {
  font-size: 0.875rem;
  color: #cbd5e1;
  line-height: 1.5;
  margin: 0;
}

/* Link & Contact Columns */
.footer-links h4,
.footer-contact h4,
.footer-social h4 {
  font-size: 1rem;
  margin-top: 0;
  margin-bottom: 1rem;
  color: #f59e0b; /* Matching hover accent color */
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.footer-links ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-links li {
  margin-bottom: 0.5rem;
}

.footer-links a,
.footer-contact a {
  color: #e2e8f0;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s ease-in-out;
}

.footer-links a:hover,
.footer-contact a:hover {
  color: #38bdf8;
  text-decoration: underline;
}

.footer-contact address {
  font-style: normal;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #cbd5e1;
}

.footer-contact p {
  margin: 0 0 0.5rem 0;
}

/* Social Media Icons */
.social-icons {
  display: flex;
  gap: 0.75rem;
}

.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-radius: 50%;
  text-decoration: none;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.social-link:hover {
  background-color: #2563eb;
  transform: translateY(-3px);
  color: #ffffff;
}

/* Footer Bottom Bar */
.footer-bottom {
  background-color: rgba(0, 0, 0, 0.25);
  padding: 1.25rem 1.5rem;
  font-size: 0.85rem;
  color: #94a3b8;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-bottom-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.footer-bottom p {
  margin: 0;
}

.legal-links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.legal-links a {
  color: #cbd5e1;
  text-decoration: none;
}

.legal-links a:hover {
  color: #ffffff;
  text-decoration: underline;
}

.legal-links .divider {
  color: #64748b;
}

/* --- RESPONSIVE MEDIA QUERIES --- */
@media screen and (max-width: 768px) {
  .footer-container {
    grid-template-columns: 1fr;
    gap: 2rem;
    text-align: center;
  }

  .footer-brand .footer-logo {
    margin: 0 auto 0.75rem auto;
  }

  .social-icons {
    justify-content: center;
  }

  .footer-bottom-container {
    flex-direction: column;
    text-align: center;
  }
}