/* ============================================================
   Cattle Direct Marketplace – Global Stylesheet
   Modern, responsive, farmer-friendly design
   ============================================================ */

/* ── Google Font ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── CSS Variables ── */
:root {
  --green-dark: #1a4d2e;
  --green-mid: #2d7a4f;
  --green-light: #4caf7d;
  --green-pale: #e8f5ee;
  --amber: #f59e0b;
  --amber-dark: #d97706;
  --red: #ef4444;
  --red-pale: #fef2f2;
  --text-dark: #1a2332;
  --text-mid: #4b5563;
  --text-light: #9ca3af;
  --bg: #f7f9f5;
  --white: #ffffff;
  --border: #d1d5db;
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, .08);
  --shadow-md: 0 4px 18px rgba(0, 0, 0, .12);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, .16);
  --radius: 14px;
  --radius-sm: 8px;
  --transition: .2s ease;
}

/* ── Reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text-dark);
  line-height: 1.6;
  min-height: 100vh;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
}

/* ── Utility ── */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* ═══════════════════════════ HEADER ═══════════════════════════ */
header {
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
  color: var(--white);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, .15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.logo-text h1 {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -.3px;
}

.logo-text p {
  font-size: .72rem;
  opacity: .8;
  margin-top: 1px;
}

nav {
  display: flex;
  gap: 8px;
}

nav a {
  padding: 9px 18px;
  border-radius: 50px;
  font-size: .88rem;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
}

nav a:hover {
  background: rgba(255, 255, 255, .15);
}

nav a.nav-cta {
  background: var(--amber);
  color: var(--text-dark);
}

nav a.nav-cta:hover {
  background: var(--amber-dark);
}

/* Language Switcher */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, .12);
  border-radius: 50px;
  padding: 4px 6px;
}

.lang-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, .75);
  font-family: inherit;
  font-size: .78rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 50px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.lang-btn:hover {
  background: rgba(255, 255, 255, .2);
  color: var(--white);
}

.lang-btn.lang-active {
  background: var(--amber);
  color: var(--text-dark);
}

/* Optional field tag */
.optional-tag {
  font-size: .75rem;
  font-weight: 500;
  color: var(--text-light);
  margin-left: 4px;
}

/* ═══════════════════════════ HERO BANNER ══════════════════════ */
.hero {
  background: linear-gradient(160deg, var(--green-dark) 0%, var(--green-mid) 60%, var(--green-light) 100%);
  color: var(--white);
  text-align: center;
  padding: 60px 20px 80px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '🐄';
  position: absolute;
  font-size: 260px;
  opacity: .05;
  top: -40px;
  right: -30px;
  line-height: 1;
  pointer-events: none;
}

.hero h2 {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  font-weight: 800;
  line-height: 1.2;
}

.hero p {
  font-size: 1.05rem;
  opacity: .85;
  margin: 12px auto 0;
  max-width: 560px;
}

/* Stats bar */
.stats-bar {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-top: 32px;
  padding: 20px 28px;
  background: rgba(255, 255, 255, .12);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.stat-item {
  text-align: center;
}

.stat-item strong {
  display: block;
  font-size: 1.6rem;
  font-weight: 800;
}

.stat-item span {
  font-size: .8rem;
  opacity: .8;
}

/* ═══════════════════════════ SEARCH/FILTER BAR ════════════════ */
.filter-section {
  background: var(--white);
  box-shadow: var(--shadow-md);
  padding: 22px 20px;
  position: relative;
  z-index: 10;
}

.filter-inner {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 12px;
  align-items: end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-group label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.filter-group input,
.filter-group select {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .9rem;
  color: var(--text-dark);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  min-width: 120px;
}

.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(45, 122, 79, .15);
}

.btn-filter {
  padding: 11px 24px;
  background: var(--green-mid);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  white-space: nowrap;
}

.btn-filter:hover {
  background: var(--green-dark);
  transform: translateY(-1px);
}

.btn-reset {
  padding: 11px 16px;
  background: transparent;
  color: var(--text-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .88rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-reset:hover {
  background: var(--bg);
  color: var(--text-dark);
}

/* ═══════════════════════════ LISTINGS GRID ════════════════════ */
.listings-section {
  padding: 40px 20px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.section-header h3 {
  font-size: 1.3rem;
  font-weight: 700;
}

.listing-count {
  color: var(--text-mid);
  font-size: .9rem;
}

.sort-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .88rem;
  cursor: pointer;
  background: var(--white);
}

.sort-select:focus {
  outline: none;
  border-color: var(--green-mid);
}

/* Grid */
.cows-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 24px;
}

/* ── Cow Card ── */
.cow-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
}

.cow-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.card-image-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--green-pale);
}

.card-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .4s ease;
}

.cow-card:hover .card-image-wrap img {
  transform: scale(1.04);
}

.card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--green-dark);
  color: var(--white);
  font-size: .72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.card-price-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--amber);
  color: var(--text-dark);
  font-size: .9rem;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 50px;
}

.card-body {
  padding: 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-dark);
}

.card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.meta-item {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meta-item .meta-label {
  font-size: .7rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .4px;
  font-weight: 600;
}

.meta-item .meta-value {
  font-size: .92rem;
  font-weight: 600;
  color: var(--text-dark);
}

.card-location {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-mid);
  font-size: .88rem;
}

.card-seller {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.seller-info .seller-name {
  font-weight: 700;
  font-size: .9rem;
}

.seller-info .seller-joined {
  font-size: .75rem;
  color: var(--text-light);
}

.btn-contact {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  background: var(--green-light);
  color: var(--white);
  border: none;
  border-radius: 50px;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition);
  white-space: nowrap;
}

.btn-contact:hover {
  background: var(--green-mid);
}

/* ── Empty / Loading states ── */
.state-box {
  text-align: center;
  padding: 70px 20px;
  grid-column: 1 / -1;
  color: var(--text-light);
}

.state-box .state-icon {
  font-size: 60px;
  margin-bottom: 16px;
}

.state-box h3 {
  font-size: 1.2rem;
  color: var(--text-mid);
  margin-bottom: 8px;
}

.state-box p {
  font-size: .9rem;
}

/* Loading spinner */
.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid var(--border);
  border-top-color: var(--green-mid);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ═══════════════════════════ SELL PAGE ════════════════════════ */
.sell-page {
  padding: 50px 20px 80px;
}

.sell-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-width: 700px;
  margin: 0 auto;
  overflow: hidden;
}

.sell-card-header {
  background: linear-gradient(135deg, var(--green-dark), var(--green-mid));
  color: var(--white);
  padding: 30px 32px;
}

.sell-card-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.sell-card-header p {
  opacity: .8;
  font-size: .92rem;
}

.sell-card-body {
  padding: 32px;
}

/* Section dividers within form */
.form-section-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--green-mid);
  margin: 24px 0 14px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--green-pale);
}

.form-section-title:first-of-type {
  margin-top: 0;
}

/* Form fields */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}

.form-group label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-dark);
}

.form-group label .required {
  color: var(--red);
  margin-left: 2px;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .9rem;
  color: var(--text-dark);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(45, 122, 79, .15);
  background: var(--white);
}

.form-group input.invalid {
  border-color: var(--red);
}

.field-error {
  font-size: .78rem;
  color: var(--red);
  min-height: 16px;
  display: block;
}

/* Image upload area */
.image-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
}

.image-upload-area:hover,
.image-upload-area.dragover {
  border-color: var(--green-mid);
  background: var(--green-pale);
}

.image-upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
}

.upload-icon {
  font-size: 42px;
  margin-bottom: 10px;
}

.upload-label {
  font-size: .92rem;
  font-weight: 600;
  color: var(--green-mid);
}

.upload-hint {
  font-size: .78rem;
  color: var(--text-light);
  margin-top: 4px;
}

.image-preview {
  margin-top: 14px;
  display: none;
}

.image-preview img {
  max-height: 200px;
  border-radius: var(--radius-sm);
  margin: 0 auto;
  object-fit: cover;
}

/* Submit button */
.btn-submit {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, var(--green-mid), var(--green-dark));
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 24px;
  transition: opacity var(--transition), transform var(--transition);
  letter-spacing: .3px;
}

.btn-submit:hover:not(:disabled) {
  opacity: .9;
  transform: translateY(-1px);
}

.btn-submit:disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* Alert messages */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  margin-top: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success {
  background: var(--green-pale);
  color: var(--green-dark);
  border-left: 4px solid var(--green-mid);
}

.alert-error {
  background: var(--red-pale);
  color: #b91c1c;
  border-left: 4px solid var(--red);
}

/* ═══════════════════════════ MODAL ════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: var(--white);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: scale(.94);
  transition: transform .25s ease;
}

.modal-overlay.active .modal-box {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
  background: var(--green-pale);
  border-bottom: 1px solid var(--border);
}

.modal-header h4 {
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-close {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background var(--transition);
}

.modal-close:hover {
  background: var(--border);
}

.modal-body {
  padding: 24px 22px;
}

.modal-cow-name {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.contact-method {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.contact-method:last-child {
  border-bottom: none;
}

.contact-icon {
  font-size: 1.4rem;
}

.contact-label {
  font-size: .78rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 2px;
  font-weight: 600;
}

.contact-value {
  font-size: 1rem;
  font-weight: 700;
}

.contact-value a {
  color: var(--green-mid);
}

.contact-value a:hover {
  text-decoration: underline;
}

/* ═══════════════════════════ FOOTER ═══════════════════════════ */
footer {
  background: var(--green-dark);
  color: var(--white);
  padding: 40px 20px 24px;
  margin-top: 60px;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
}

.footer-brand h3 {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.footer-brand p {
  font-size: .88rem;
  opacity: .7;
  max-width: 280px;
  line-height: 1.7;
}

.footer-col h4 {
  font-size: .88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 14px;
  opacity: .6;
}

.footer-col ul li {
  margin-bottom: 8px;
}

.footer-col ul li a {
  font-size: .88rem;
  opacity: .8;
  transition: opacity var(--transition);
}

.footer-col ul li a:hover {
  opacity: 1;
}

.footer-bottom {
  max-width: 1200px;
  margin: 30px auto 0;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, .15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .82rem;
  opacity: .6;
}

/* ═══════════════════════════ RESPONSIVE ═══════════════════════ */
@media (max-width: 900px) {
  .filter-inner {
    grid-template-columns: 1fr 1fr;
  }

  .footer-inner {
    grid-template-columns: 1fr 1fr;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}

@media (max-width: 640px) {
  .header-inner {
    flex-wrap: wrap;
    gap: 10px;
  }

  nav a:not(.nav-cta) {
    display: none;
  }

  .hero {
    padding: 40px 20px 60px;
  }

  .stats-bar {
    flex-direction: column;
    gap: 18px;
    padding: 18px 24px;
  }

  .filter-inner {
    grid-template-columns: 1fr;
  }

  .cows-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .footer-inner {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .sell-card-body {
    padding: 20px;
  }
}