/* ==========================================================================
   Farmer Membership Management System — base stylesheet
   A small, self-contained utility/component CSS framework (no external
   CDN or build step required). Class names are Bootstrap-5-compatible
   so templates stay readable, but this is a lightweight original
   stylesheet, not the Bootstrap library itself — the app ships fully
   offline-capable without needing to fetch anything after install.
   ========================================================================== */

:root {
  --brand: #1e7d32;
  --brand-dark: #14532a;
  --brand-light: #e9f5ea;
  --brand-gradient: linear-gradient(135deg, #1e7d32 0%, #2fa84f 100%);
  --text: #1f2933;
  --muted: #6b7280;
  --border: #e4e8e5;
  --bg: #f5f7f5;
  --danger: #c0392b;
  --warning: #b8860b;
  --success: #1e7d32;
  --info: #2563eb;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(16,24,20,.06), 0 1px 1px rgba(16,24,20,.04);
  --shadow-md: 0 6px 20px rgba(16,24,20,.08);
  --shadow-lg: 0 16px 40px rgba(16,24,20,.14);
}

* { box-sizing: border-box; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  margin: 0;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4,h5 { margin-top: 0; font-weight: 700; letter-spacing: -.01em; }
svg { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.container { max-width: 1140px; margin: 0 auto; padding: 0 16px; }
.container-sm { max-width: 560px; margin: 0 auto; padding: 0 16px; }

/* Grid */
.row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.row > [class*="col"] { padding: 0 8px; }
.col { flex: 1 0 0%; }
.col-2 { flex: 0 0 16.6667%; max-width: 16.6667%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.3333%; max-width: 33.3333%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-8 { flex: 0 0 66.6667%; max-width: 66.6667%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }
@media (max-width: 768px) {
  .row > [class*="col"] { flex: 0 0 100%; max-width: 100%; margin-bottom: 10px; }
}

/* Navbar */
.navbar { background: var(--brand-dark); background: linear-gradient(180deg, #16391f 0%, #14532a 100%); color: #fff; padding: 14px 0; box-shadow: 0 2px 10px rgba(0,0,0,.12); position: relative; z-index: 5; }
.navbar .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.navbar a { color: #fff; }
.navbar-brand { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.navbar-brand img { height: 32px; width: auto; max-width: 210px; object-fit: contain; border-radius: 6px; background: #fff; padding: 2px 6px; }
.navbar-brand .brand-icon { width: 34px; height: 34px; border-radius: 8px; background: rgba(255,255,255,.14); display: flex; align-items: center; justify-content: center; }
.navbar-nav { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; align-items: center; }
.navbar-nav a { opacity: .92; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; transition: background .15s ease, opacity .15s ease; }
.navbar-nav a:hover { opacity: 1; background: rgba(255,255,255,.12); text-decoration: none; }
.navbar-nav a.btn-cta { background: #fff; color: var(--brand-dark); font-weight: 600; opacity: 1; }
.navbar-nav a.btn-cta:hover { background: #eaf6ec; }

/* Sidebar (admin) */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar { width: 240px; background: linear-gradient(180deg,#16321f 0%, #122a1b 100%); color: #dfe9e2; flex-shrink: 0; }
.admin-sidebar .brand { padding: 20px 18px; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 10px; }
.admin-sidebar .brand .brand-icon { width: 32px; height: 32px; border-radius: 8px; background: rgba(255,255,255,.12); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.admin-sidebar nav { padding: 10px 8px; }
.admin-sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; color: #c8dccd; font-size: 14px; border-radius: 8px; margin-bottom: 2px; border-left: 3px solid transparent; transition: background .15s ease, color .15s ease; }
.admin-sidebar nav a svg { opacity: .85; flex-shrink: 0; }
.admin-sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.admin-sidebar nav a.active { background: rgba(111,191,115,.16); border-left-color: #6fbf73; color: #fff; }
.admin-sidebar nav a.active svg { opacity: 1; color: #8fdc93; }
.admin-sidebar nav .nav-divider { height: 1px; background: rgba(255,255,255,.08); margin: 8px 10px; }
.admin-main { flex: 1; min-width: 0; }
.admin-topbar { background: #fff; border-bottom: 1px solid var(--border); padding: 14px 22px; display: flex; justify-content: space-between; align-items: center; box-shadow: var(--shadow-sm); position: relative; z-index: 2; }
.admin-content { padding: 22px; }
@media (max-width: 900px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; }
}

/* Cards / panels */
.panel, .card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.panel-header, .card-header-ui { padding: 15px 18px; border-bottom: 1px solid var(--border); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.panel-body, .card-body-ui { padding: 18px; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); display: flex; align-items: flex-start; gap: 14px; transition: transform .15s ease, box-shadow .15s ease; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-icon { width: 42px; height: 42px; border-radius: 10px; background: var(--brand-light); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-card .stat-icon.warning { background: #fff3da; color: var(--warning); }
.stat-card .stat-icon.danger { background: #fbe6e3; color: var(--danger); }
.stat-card .stat-icon.info { background: #e3ecfd; color: var(--info); }
.stat-card .stat-icon.secondary { background: #eef0f1; color: #6b7280; }
.stat-card .num { font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat-card .label { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 18px; border-radius: 999px; border: 1px solid transparent; cursor: pointer; font-size: 14px; font-weight: 600; text-align: center; transition: background .15s ease, border-color .15s ease, transform .1s ease, box-shadow .15s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-gradient); border-color: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(30,125,50,.28); }
.btn-primary:hover { filter: brightness(1.05); text-decoration: none; box-shadow: 0 4px 14px rgba(30,125,50,.34); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); text-decoration: none; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-block { display: flex; width: 100%; }

/* Forms */
.form-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.form-control, .form-select, textarea.form-control {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; background: #fff; color: var(--text); transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus, .form-select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(30,125,50,.12); }
.mb-3 { margin-bottom: 14px; }
.form-text { font-size: 12px; color: var(--muted); margin-top: 3px; }
.is-invalid { border-color: var(--danger) !important; }
.invalid-feedback { font-size: 12px; color: var(--danger); }
.form-check-inline { display: inline-flex; align-items: center; gap: 4px; margin-right: 14px; }

/* Table */
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.table th, table.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; }
table.table th { background: #fafbfa; font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.table tbody tr:hover { background: #fafcfa; }
.table-responsive { overflow-x: auto; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; letter-spacing: .02em; }
.badge-success { background: var(--success); }
.badge-warning { background: var(--warning); }
.badge-secondary { background: #6b7280; }
.badge-dark { background: #1f2933; }
.badge-danger { background: var(--danger); }

/* Alerts */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; display: flex; align-items: flex-start; gap: 10px; }
.alert-success { background: #eaf6ec; color: #1e7d32; border: 1px solid #bfe3c4; }
.alert-danger { background: #fbeaea; color: #a72a20; border: 1px solid #f0c4c0; }
.alert-warning { background: #fff8e6; color: #8a6100; border: 1px solid #f2debf; }
.alert-info { background: #eaf1fd; color: #1d4ed8; border: 1px solid #c4d7f7; }

/* Pagination */
.pagination { list-style: none; display: flex; gap: 4px; padding: 0; }
.page-item .page-link { display: block; padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 13px; }
.page-item.active .page-link { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Hero (public home page) */
.hero { background: var(--brand-gradient); border-radius: 16px; color: #fff; padding: 56px 32px; text-align: center; box-shadow: var(--shadow-lg); position: relative; overflow: hidden; margin-bottom: 26px; }
.hero::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 15% 20%, rgba(255,255,255,.12), transparent 40%), radial-gradient(circle at 85% 80%, rgba(255,255,255,.10), transparent 40%); }
.hero > * { position: relative; }
.hero .hero-icon { width: 64px; height: 64px; border-radius: 16px; background: rgba(255,255,255,.16); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.hero h1 { font-size: 30px; margin-bottom: 8px; }
.hero p { opacity: .92; max-width: 520px; margin: 0 auto 22px; }
.hero .btn-outline { background: transparent; border-color: rgba(255,255,255,.5); color: #fff; }
.hero .btn-outline:hover { background: rgba(255,255,255,.14); border-color: #fff; }

.feature-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); height: 100%; transition: transform .15s ease, box-shadow .15s ease; }
.feature-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.feature-card .feature-icon { width: 44px; height: 44px; border-radius: 10px; background: var(--brand-light); color: var(--brand); display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.feature-card h3 { font-size: 16px; margin-bottom: 6px; }
.feature-card p { color: var(--muted); font-size: 13.5px; margin: 0; }
.feature-step { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 6px; }

/* Membership Card */
.membership-card {
  width: 400px; max-width: 100%; border-radius: 12px; overflow: hidden; background: #fff;
  box-shadow: 0 6px 24px rgba(0,0,0,.12); border: 1px solid var(--border); font-size: 13px;
}
.membership-card .card-header { background: var(--card-primary, var(--brand)); color: var(--card-text, #fff); padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.membership-card .card-logo { height: 34px; width: auto; max-width: 90px; object-fit: contain; background: #fff; border-radius: 4px; padding: 2px 4px; }
.membership-card .card-org-name { font-weight: 700; font-size: 15px; }
.membership-card .card-title { font-size: 11px; opacity: .9; letter-spacing: .06em; }
.membership-card .card-body { display: flex; gap: 12px; padding: 14px 16px; align-items: flex-start; }
.membership-card .card-photo { width: 78px; height: 92px; object-fit: cover; border: 1px solid var(--border); border-radius: 6px; background: #f0f0f0; }
.membership-card .card-status { text-align: center; font-size: 10px; font-weight: 700; margin-top: 6px; padding: 2px 4px; border-radius: 4px; color: #fff; }
.membership-card .card-farmer-sign { text-align: center; margin-top: 6px; }
.membership-card .card-farmer-sign img { height: 26px; width: auto; max-width: 78px; object-fit: contain; }
.membership-card .card-farmer-sign-label { font-size: 8px; color: var(--muted); border-top: 1px solid var(--border); margin-top: 1px; padding-top: 1px; }
.membership-card .badge-status-active { background: var(--success); }
.membership-card .badge-status-expired { background: #6b7280; }
.membership-card .badge-status-suspended { background: #1f2933; }
.membership-card .badge-status-pending { background: var(--warning); }
.membership-card .card-name { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.membership-card .card-fields { width: 100%; border-collapse: collapse; }
.membership-card .card-fields td { padding: 2px 4px 2px 0; font-size: 12px; vertical-align: top; }
.membership-card .card-fields td:first-child { color: var(--muted); white-space: nowrap; padding-right: 8px; }
.membership-card .card-qr-col { text-align: center; flex-shrink: 0; }
.membership-card .card-sign-stamp-row { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 8px; }
.membership-card .card-signature { height: auto; max-height: 38px; width: auto; max-width: 105px; object-fit: contain; }
.membership-card .card-stamp { height: auto; max-height: 62px; width: auto; max-width: 75px; object-fit: contain; opacity: .9; }
.membership-card .card-footer { background: var(--card-secondary, #f5f5f5); padding: 8px 16px; font-size: 11px; color: var(--muted); }

@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; top: 0; left: 0; }
  .no-print { display: none !important; }
}

.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.mt-3 { margin-top: 14px; }
.mb-0 { margin-bottom: 0; }
.w-100 { width: 100%; }

/* Farmer Registration Certificate (Agriculture Project) */
.certificate {
  max-width: 780px; margin: 0 auto; background: #fff; border: 3px double #14532a; border-radius: 4px;
  padding: 36px 44px; font-family: 'Noto Sans Devanagari', 'Mangal', 'Nirmala UI', Arial, sans-serif;
  color: #1f2933; line-height: 1.6;
}
.cert-header { text-align: center; margin-bottom: 6px; }
.cert-logo { height: 46px; width: auto; max-width: 220px; object-fit: contain; margin-bottom: 8px; }
.cert-org-name { font-size: 17px; font-weight: 700; color: var(--brand-dark); }
.cert-project-line { font-size: 13px; font-weight: 600; color: var(--brand); margin-top: 2px; }
.cert-area-line { font-size: 12px; color: var(--muted); }
.cert-title { text-align: center; font-size: 20px; margin: 18px 0 4px; color: #1f2933; }
.cert-subtitle { text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.cert-no { text-align: right; font-size: 13px; margin-bottom: 14px; }
.cert-intro { font-size: 14px; }
.cert-en { color: var(--muted); font-size: 12.5px; }
table.cert-fields { width: 100%; border-collapse: collapse; margin: 10px 0 16px; font-size: 13.5px; }
table.cert-fields td { padding: 6px 8px; border-bottom: 1px dashed #dfe3e6; }
table.cert-fields td:first-child { width: 46%; color: #374151; }
.cert-section-title { font-size: 15px; color: var(--brand-dark); border-bottom: 2px solid var(--brand-light); padding-bottom: 4px; margin-top: 22px; }
.cert-terms { font-size: 13px; padding-left: 20px; }
.cert-terms li { margin-bottom: 6px; }
.cert-declaration { font-size: 13.5px; background: #fafbfa; border: 1px solid var(--border); border-radius: 6px; padding: 12px; }
.cert-signatures { display: flex; justify-content: space-between; gap: 24px; margin-top: 44px; }
.cert-sign-block { flex: 1; font-size: 12.5px; text-align: center; }
.cert-sign-stamp-images { display: flex; align-items: flex-end; justify-content: center; gap: 14px; height: 145px; margin-bottom: 10px; }
.cert-signature-img { height: 95px; width: auto; max-width: 175px; object-fit: contain; }
.cert-stamp-img { height: 145px; width: auto; max-width: 135px; object-fit: contain; opacity: .9; }
.cert-sign-line { border-top: 1px solid #333; margin-bottom: 6px; height: 40px; }
.cert-sign-date, .cert-sign-meta { margin-top: 8px; color: var(--muted); text-align: left; }
.cert-tagline { text-align: center; margin-top: 30px; font-size: 12.5px; color: var(--brand-dark); font-weight: 600; letter-spacing: .02em; }

@media print {
  .certificate { border-width: 2px; box-shadow: none; }
}

/* Enhanced file upload widget — status pill turns green once a file is chosen/on file */
.upload-field { margin-bottom: 4px; }
.upload-dropzone { display: block; cursor: pointer; }
.upload-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.upload-status {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: var(--radius-sm);
  border: 1.5px dashed var(--border); background: #fafbfa; color: var(--muted); font-size: 13.5px;
  transition: background .15s ease, border-color .15s ease, color .15s ease; width: 100%;
}
.upload-status:hover { border-color: var(--brand); color: var(--brand); }
.upload-status .upload-icon-filled { display: none; }
.upload-status.has-file { background: var(--brand-light); border-color: var(--brand); border-style: solid; color: var(--brand-dark); font-weight: 600; }
.upload-status.has-file .upload-icon-empty { display: none; }
.upload-status.has-file .upload-icon-filled { display: inline-flex; color: var(--brand); }
.upload-preview { margin-top: 8px; }
.upload-preview img { height: 52px; width: auto; max-width: 160px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; background: #fff; padding: 3px; }

/* Password field with show/hide toggle */
.password-field { position: relative; }
.password-field .form-control { padding-right: 42px; }
.password-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: none;
  cursor: pointer; padding: 6px; color: var(--muted); display: flex; align-items: center; border-radius: 6px;
}
.password-toggle:hover { color: var(--brand); background: var(--brand-light); }
.password-toggle .pwd-icon-hide { display: none; }
.password-toggle.showing .pwd-icon-show { display: none; }
.password-toggle.showing .pwd-icon-hide { display: inline-flex; }

/* ==========================================================================
   Mobile responsiveness — most visitors use this app on a phone.
   ========================================================================== */
@media (max-width: 640px) {
  .container, .container-sm { padding: 0 12px; }
  body { font-size: 15px; }

  /* Navbar: stack brand and nav, full-width tap targets */
  .navbar { padding: 10px 0; }
  .navbar .container { flex-direction: column; align-items: flex-start; gap: 8px; }
  .navbar-nav { width: 100%; gap: 4px; }
  .navbar-nav a { flex: 1 1 auto; justify-content: center; padding: 9px 10px; font-size: 13.5px; }

  /* Hero */
  .hero { padding: 32px 18px; border-radius: 12px; }
  .hero h1 { font-size: 22px; }
  .hero .btn { width: 100%; }
  .hero .d-flex { flex-direction: column; }

  /* Panels/cards: less padding, still readable */
  .panel-header, .card-header-ui { padding: 12px 14px; font-size: 14.5px; }
  .panel-body, .card-body-ui { padding: 14px; }
  h1 { font-size: 22px; } h2 { font-size: 19px; } h3 { font-size: 16.5px; } h4 { font-size: 15px; }

  /* Stat grid: 2 columns instead of auto-fit on very small screens */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-card .num { font-size: 20px; }

  /* Buttons: full-width and stacked where they were inline */
  .d-flex.gap-2 { flex-wrap: wrap; }
  .btn { padding: 10px 16px; font-size: 14px; }

  /* Forms: single column, larger touch targets */
  .form-control, .form-select { padding: 11px 12px; font-size: 16px; } /* 16px avoids iOS zoom-on-focus */
  .password-toggle { padding: 10px; }

  /* Tables: allow horizontal scroll without breaking layout */
  table.table th, table.table td { padding: 8px; font-size: 13px; }

  /* Admin shell */
  .admin-sidebar .brand { padding: 14px; }
  .admin-topbar { padding: 10px 14px; flex-direction: column; align-items: flex-start; gap: 6px; }
  .admin-content { padding: 14px; }

  /* Membership card and certificate: scale to fit narrow screens without horizontal scroll */
  .membership-card { width: 100%; font-size: 12px; }
  .membership-card .card-body { flex-wrap: wrap; }
  .membership-card .card-photo { width: 64px; height: 76px; }
  .certificate { padding: 18px 14px; }
  .cert-title { font-size: 16px; }
  .cert-signatures { flex-direction: column; gap: 24px; }
  table.cert-fields td:first-child { width: 55%; }

  /* Upload widget */
  .upload-status { padding: 10px 12px; font-size: 13px; }
}

@media (max-width: 400px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .card-fields, table.cert-fields { font-size: 11.5px; }
}
