/**
 * AGRI-DATA SMART — extra responsive tweaks (website + shared)
 */
:root {
  --agri-page-gutter: clamp(14px, 2.8vw, 40px);
  --agri-content-max: 1360px;
}

.agri-page-shell {
  width: min(var(--agri-content-max), calc(100% - 2 * var(--agri-page-gutter)));
  max-width: none;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  overscroll-behavior-y: none;
}

body.index-page {
  overflow-x: hidden;
  overscroll-behavior: none;
  overscroll-behavior-y: none;
}

/* Topbar — stack on small phones; allow full height so text is not clipped */
@media (max-width: 767px) {
  .header .topbar {
    height: auto;
    min-height: 40px;
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    padding-bottom: 8px;
    align-items: stretch;
    overflow: visible;
  }

  .header .topbar .contact-info i a,
  .header .topbar .contact-info i span {
    line-height: 1.4;
  }

  .header .topbar .social-links a {
    line-height: 1;
  }
}

@media (max-width: 767.98px) {
  .header .topbar .topbar-social-desktop {
    display: none !important;
  }
}

@media (max-width: 575px) {
  .header .topbar .container.topbar-inner {
    flex-direction: column;
    gap: 6px;
    padding-top: 4px;
    padding-bottom: 4px;
  }

  .header .topbar .contact-info {
    flex-direction: column;
    align-items: center !important;
    gap: 6px;
    width: 100%;
  }

  .header .topbar .contact-info > .bi-envelope {
    justify-content: center;
    text-align: center;
    flex-wrap: wrap;
  }

  .header .topbar .contact-phone-social {
    justify-content: center;
    gap: 14px;
    flex-wrap: nowrap;
  }

  .header .topbar .topbar-social-inline {
    gap: 10px;
  }

  .header .topbar .topbar-social-inline a {
    margin-left: 0;
  }
}

@media (min-width: 576px) and (max-width: 767.98px) {
  .header .topbar .contact-info {
    gap: 2rem;
  }

  .header .topbar .contact-phone-social {
    margin-left: 0;
  }
}

/* Desktop — email + phone left (spaced), social icons far right */
@media (min-width: 768px) {
  .header .topbar .topbar-inner {
    width: 100%;
  }

  .header .topbar .contact-info {
    gap: 3rem;
    flex-wrap: nowrap;
  }

  .header .topbar .contact-phone-social {
    margin-left: 0;
  }

  .header .topbar .topbar-social-desktop {
    flex-shrink: 0;
    gap: 6px;
    margin-left: auto;
  }

  .header .topbar .topbar-social-desktop a {
    margin-left: 16px;
    margin-right: 0;
  }

  .header .topbar .topbar-social-desktop a:first-child {
    margin-left: 0;
  }
}

/* Branding / logo on phones */
@media (max-width: 767px) {
  .header .logo h1,
  .header .logo .sitename {
    font-size: 1rem !important;
  }

  .header .logo img {
    max-height: 44px !important;
  }

  .header .branding {
    padding: 8px 0;
  }
}

/* ── Mobile nav drawer (hamburger menu) ── */
@media (min-width: 1200px) {
  .mobile-nav-only {
    display: none !important;
  }

  .navmenu .nav-icon {
    display: none;
  }

  .mobile-nav-logout-item .mobile-nav-logout {
    background: none;
    border: none;
    color: var(--nav-color);
    font-family: var(--nav-font);
    font-size: 16px;
    font-weight: 400;
    padding: 18px 15px;
    cursor: pointer;
  }

  .mobile-nav-logout-item .mobile-nav-logout:hover {
    color: var(--nav-hover-color);
  }
}

@media (max-width: 1199px) {
  .desktop-nav-only {
    display: none !important;
  }

  .mobile-nav-active .navmenu {
    background: rgba(18, 48, 30, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }

  .mobile-nav-active .mobile-nav-toggle {
    top: max(10px, env(safe-area-inset-top, 0px));
    right: 12px;
    width: 44px;
    height: 44px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    color: #fff !important;
    line-height: 1;
    transition: background 0.2s, transform 0.2s;
  }

  .mobile-nav-active .mobile-nav-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
  }

  .mobile-nav-active .navmenu > ul {
    inset: auto;
    top: max(76px, calc(env(safe-area-inset-top, 0px) + 68px));
    left: 14px;
    right: 14px;
    bottom: auto;
    max-height: min(82dvh, calc(100dvh - 96px));
    padding: 0;
    margin: 0;
    border-radius: 16px;
    overflow: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.28);
    animation: agriMobileNavIn 0.3s ease-out;
  }

  @keyframes agriMobileNavIn {
    from {
      opacity: 0;
      transform: translateY(-12px) scale(0.98);
    }
    to {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }

  .mobile-nav-head {
    list-style: none;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #4aad68 0%, #5cb874 50%, #3d9658 100%);
  }

  .mobile-nav-head-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    color: #fff;
  }

  .mobile-nav-head-inner img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.35);
    flex-shrink: 0;
  }

  .mobile-nav-head-inner strong {
    display: block;
    font-family: var(--nav-font);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.2;
  }

  .mobile-nav-head-inner span {
    display: block;
    font-size: 0.72rem;
    opacity: 0.85;
    font-weight: 400;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }

  .navmenu ul > li:not(.mobile-nav-head):not(.mobile-nav-divider):not(.mobile-nav-section-label):not(.mobile-nav-user) {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  }

  .navmenu ul > li:last-child {
    border-bottom: none;
  }

  .navmenu a,
  .navmenu a:focus {
    padding: 14px 18px !important;
    font-size: 0.95rem !important;
    font-weight: 500 !important;
    gap: 14px;
    justify-content: flex-start !important;
    white-space: normal;
  }

  .navmenu a .nav-icon {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
    color: var(--accent-color);
    flex-shrink: 0;
    margin: 0 !important;
    background: none !important;
    border-radius: 0 !important;
    height: auto !important;
    line-height: 1 !important;
  }

  .navmenu a.active,
  .navmenu a.active:focus {
    background: rgba(92, 184, 116, 0.1);
    color: var(--accent-color) !important;
    border-left: 3px solid var(--accent-color);
    padding-left: 15px !important;
  }

  .navmenu a:hover {
    background: rgba(92, 184, 116, 0.07);
    color: var(--accent-color) !important;
  }

  .mobile-nav-divider {
    list-style: none;
    height: 1px;
    margin: 6px 18px;
    background: rgba(0, 0, 0, 0.08);
    padding: 0 !important;
  }

  .mobile-nav-section-label {
    list-style: none;
    padding: 10px 18px 4px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #999;
  }

  .mobile-nav-user {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    margin: 0;
    background: rgba(92, 184, 116, 0.08);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--heading-color);
  }

  .mobile-nav-user i {
    font-size: 1.5rem;
    color: var(--accent-color);
    flex-shrink: 0;
  }

  .mobile-nav-logout-item {
    list-style: none;
    padding: 12px 18px 16px;
    margin: 0;
    border-bottom: none !important;
  }

  .mobile-nav-logout-form {
    margin: 0;
    width: 100%;
  }

  .mobile-nav-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid rgba(92, 184, 116, 0.45);
    border-radius: 10px;
    background: #fff;
    color: #c0392b;
    font-family: var(--nav-font);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
  }

  .mobile-nav-logout .nav-icon {
    color: #c0392b;
    font-size: 1.1rem;
    width: auto;
  }

  .mobile-nav-logout:hover {
    background: #fff5f5;
    border-color: #c0392b;
    color: #a93226;
  }
}

/* Sections & containers */
@media (max-width: 991px) {
  section,
  .section {
    padding: 48px 0;
  }

  .container {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 575px) {
  section,
  .section {
    padding: 36px 0;
  }

  .section-title h2 {
    font-size: 1.45rem;
  }
}

/* Website header aligns with page margins */
@media (max-width: 1199px) {
  .header .topbar .container,
  .header .branding .container {
    max-width: none;
    width: min(var(--agri-content-max), calc(100% - 2 * var(--agri-page-gutter)));
    padding-left: 0;
    padding-right: 0;
  }
}

/* Contact section */
@media (max-width: 767px) {
  .contact .info-wrap {
    margin-bottom: 24px;
  }

  .contact .info-item {
    flex-direction: row;
    align-items: flex-start !important;
  }

  .contact .php-email-form .btn {
    width: 100%;
  }
}

/* Role cards / services grids */
@media (max-width: 575px) {
  .register-role-card,
  .service-item {
    margin-bottom: 12px;
  }
}

/* Footer */
@media (max-width: 767px) {
  .footer .footer-top {
    text-align: center;
  }

  .footer .social-links {
    justify-content: center;
  }
}

/* Prevent horizontal scroll from wide elements */
img,
video,
iframe {
  max-width: 100%;
  height: auto;
}

/* Dashboard profile avatars — fixed size, never stretch with global img rules */
img.ext-nav-profile-img {
  width: 34px;
  height: 34px;
  min-width: 34px;
  max-width: 34px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: center;
}

img.profile-thumb {
  width: 52px;
  height: 52px;
  min-width: 52px;
  max-width: 52px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: center;
}

img.profile-photo-preview {
  width: 120px;
  height: 120px;
  min-width: 120px;
  max-width: 120px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: center;
}

.table-responsive,
.dash-scroll-table,
.admin-table-wrap {
  -webkit-overflow-scrolling: touch;
}

/* Dashboard layouts — mobile & tablet */
@media (max-width: 991px) {
  .admin-dash-header {
    grid-template-columns: 1fr !important;
  }

  .admin-dash-search {
    width: 100%;
    max-width: none;
  }

  .admin-dash-date {
    justify-self: start;
  }

  .feedback-dash-header {
    flex-direction: column;
    align-items: flex-start !important;
  }

  .feedback-header-stats {
    margin-left: 0;
    justify-content: flex-start;
  }

  .card-header-agri .d-flex.gap-3 {
    width: 100%;
  }
}

@media (max-width: 767px) {
  .admin-stat-card .card-body {
    padding: 12px;
  }

  .admin-action-col {
    min-width: 140px;
  }

  .admin-btn-view,
  .admin-btn-delete,
  .admin-btn-download {
    font-size: 0.75rem;
    padding: 5px 8px;
  }

  .feedback-bulk-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .feedback-bulk-delete-btn {
    width: 100%;
    justify-content: center;
  }

  .dash-profile-strip {
    flex-direction: column;
    text-align: center;
  }

  .dash-profile-strip .profile-info {
    width: 100%;
  }

  .dash-role-pill {
    align-self: center;
  }
}

@media (max-width: 575px) {
  .admin-page-title {
    font-size: 1.1rem !important;
  }

  .admin-dash-header-title .admin-dash-subtitle {
    font-size: 0.78rem;
  }

  .admin-link-light {
    font-size: 0.78rem;
  }

  .dash-quick-actions {
    flex-wrap: wrap;
  }

  .dash-quick-btn {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
    justify-content: center;
    text-align: center;
  }
}
