/* ============================================================
   AgriLink - Main Stylesheet
   Mobile-first, produce photography focus
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f8f9fa;
}

a { color: #2e7d32; text-decoration: none; }
a:hover { color: #1b5e20; text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4 { line-height: 1.3; color: #1a1a1a; }

/* ---------- Layout ---------- */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.page-content {
    min-height: calc(100vh - 140px);
    padding: 1.5rem 0;
}

/* ---------- Header ---------- */
.site-header {
    background: #2e7d32;
    color: #fff;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.5px;
}
.site-logo:hover { color: #fff; text-decoration: none; }
.site-logo-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,.3);
}
.site-logo-text { color: #fff; }

.header-nav { display: flex; align-items: center; gap: .5rem; }

.header-nav a {
    color: rgba(255,255,255,.9);
    padding: .4rem .75rem;
    border-radius: 6px;
    font-size: .9rem;
    transition: background .2s;
}
.header-nav a:hover { background: rgba(255,255,255,.15); text-decoration: none; color: #fff; }

.header-nav .btn-login {
    background: rgba(255,255,255,.2);
    font-weight: 600;
}

/* Mobile menu toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: .25rem;
}

/* ---------- Hero / Search Bar ---------- */
.hero {
    background: linear-gradient(135deg, #1b5e20 0%, #388e3c 100%);
    color: #fff;
    padding: 2.5rem 1rem 2rem;
    text-align: center;
}

.hero-logo {
    max-width: 280px;
    margin: 0 auto 1.5rem;
}
.hero-logo img {
    width: 100%;
    height: auto;
    border-radius: 16px;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,.25));
}

.hero h1 { font-size: 1.8rem; margin-bottom: .5rem; }
.hero p { font-size: 1.05rem; opacity: .9; margin-bottom: 1.5rem; }

.search-bar {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    gap: .5rem;
}

.search-bar input {
    flex: 1;
    padding: .75rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
}

.search-bar button {
    padding: .75rem 1.25rem;
    background: #ff8f00;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
}
.search-bar button:hover { background: #ff6f00; }

/* ---------- Filter Bar ---------- */
.filter-bar {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: .75rem 0;
}

.filter-inner {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.filter-bar select,
.filter-bar input[type="number"] {
    padding: .5rem .75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: .9rem;
    background: #fff;
    min-width: 0;
}

.filter-bar select { max-width: 180px; }
.filter-bar input[type="number"] { width: 100px; }

.filter-bar label {
    font-size: .85rem;
    color: #666;
    display: flex;
    align-items: center;
    gap: .25rem;
    cursor: pointer;
}

.filter-bar .filter-btn {
    padding: .5rem 1rem;
    background: #2e7d32;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: .9rem;
}
.filter-bar .filter-btn:hover { background: #1b5e20; }

.filter-bar .filter-clear {
    padding: .5rem .75rem;
    color: #666;
    font-size: .85rem;
    background: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
}

.results-count {
    font-size: .9rem;
    color: #666;
    padding: 1rem 0 .5rem;
}

/* ---------- Produce Card Grid ---------- */
.produce-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
    padding: 1rem 0;
}

.produce-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    transition: transform .2s, box-shadow .2s;
    display: flex;
    flex-direction: column;
}
.produce-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
}

.produce-card .card-image {
    position: relative;
    padding-top: 66%;
    background: #e8f5e9;
    overflow: hidden;
}

.produce-card .card-image img {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
}

.produce-card .card-image .no-image {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    opacity: .3;
}

.card-badge {
    position: absolute;
    top: .5rem;
    left: .5rem;
    padding: .2rem .6rem;
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 600;
    color: #fff;
}
.badge-organic { background: #43a047; }
.badge-featured { background: #ff8f00; }

.card-body {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-category {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #888;
    margin-bottom: .25rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: .25rem;
    color: #1a1a1a;
}
.card-title a { color: inherit; }
.card-title a:hover { color: #2e7d32; text-decoration: none; }

.card-variety {
    font-size: .9rem;
    color: #666;
    margin-bottom: .5rem;
}

.card-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2e7d32;
    margin-bottom: .25rem;
}
.card-price small { font-size: .8rem; font-weight: 400; color: #888; }

.card-meta {
    font-size: .8rem;
    color: #888;
    margin-bottom: .75rem;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.card-meta span { display: flex; align-items: center; gap: .2rem; }

.card-footer {
    margin-top: auto;
    padding-top: .75rem;
    border-top: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-producer {
    font-size: .8rem;
    color: #666;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    padding: .6rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all .2s;
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary { background: #2e7d32; color: #fff; }
.btn-primary:hover { background: #1b5e20; color: #fff; text-decoration: none; }

.btn-secondary { background: #f5f5f5; color: #333; border: 1px solid #ddd; }
.btn-secondary:hover { background: #e0e0e0; text-decoration: none; }

.btn-accent { background: #ff8f00; color: #fff; }
.btn-accent:hover { background: #ff6f00; color: #fff; text-decoration: none; }

.btn-danger { background: #d32f2f; color: #fff; }
.btn-danger:hover { background: #b71c1c; color: #fff; text-decoration: none; }

.btn-sm { padding: .4rem .75rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.75rem; font-size: 1rem; }
.btn-block { display: block; width: 100%; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Listing Detail Page ---------- */
.listing-detail {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.listing-gallery {
    position: relative;
    padding-top: 56%;
    background: #e8f5e9;
    overflow: hidden;
}

.listing-gallery img {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
}

.listing-info { padding: 1.5rem; }

.listing-info .category-tag {
    display: inline-block;
    padding: .2rem .6rem;
    background: #e8f5e9;
    color: #2e7d32;
    border-radius: 4px;
    font-size: .8rem;
    font-weight: 600;
    margin-bottom: .5rem;
}

.listing-info h1 { font-size: 1.6rem; margin-bottom: .25rem; }
.listing-info .variety { font-size: 1rem; color: #666; margin-bottom: 1rem; }

.listing-price-box {
    background: #f1f8e9;
    padding: 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.listing-price-box .price {
    font-size: 2rem;
    font-weight: 700;
    color: #2e7d32;
}
.listing-price-box .price small { font-size: 1rem; font-weight: 400; color: #666; }

.listing-price-box .stock {
    font-size: .95rem;
    color: #555;
    margin-top: .25rem;
}

.listing-attributes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
    margin-bottom: 1.5rem;
}

.listing-attr {
    padding: .75rem;
    background: #fafafa;
    border-radius: 6px;
}
.listing-attr .label { font-size: .75rem; color: #888; text-transform: uppercase; letter-spacing: .5px; }
.listing-attr .value { font-size: .95rem; font-weight: 600; color: #333; }

.listing-description { margin-bottom: 1.5rem; line-height: 1.7; color: #555; }

.add-to-cart-form {
    display: flex;
    gap: .75rem;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.add-to-cart-form .qty-group { flex: 0 0 auto; }
.add-to-cart-form .qty-group label { display: block; font-size: .85rem; color: #666; margin-bottom: .25rem; }
.add-to-cart-form .qty-group input {
    width: 100px;
    padding: .6rem .75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    text-align: center;
}

.producer-card {
    background: #fafafa;
    border-radius: 8px;
    padding: 1.25rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.producer-card .producer-info h3 { font-size: 1rem; margin-bottom: .25rem; }
.producer-card .producer-info p { font-size: .85rem; color: #666; margin: 0; }

/* ---------- Cart ---------- */
.cart-container { max-width: 800px; margin: 0 auto; }

.cart-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #888;
}
.cart-empty h2 { margin-bottom: .5rem; }

.cart-producer-group {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    margin-bottom: 1.5rem;
}

.cart-producer-header {
    background: #f5f5f5;
    padding: .75rem 1rem;
    font-weight: 600;
    font-size: .95rem;
    border-bottom: 1px solid #eee;
}

.cart-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    gap: 1rem;
}
.cart-item:last-child { border-bottom: none; }

.cart-item-image {
    width: 70px;
    height: 70px;
    border-radius: 8px;
    overflow: hidden;
    background: #e8f5e9;
    flex-shrink: 0;
}
.cart-item-image img { width: 100%; height: 100%; object-fit: cover; }

.cart-item-info { flex: 1; min-width: 0; }
.cart-item-info h4 { font-size: .95rem; margin-bottom: .15rem; }
.cart-item-info .item-price { font-size: .85rem; color: #666; }

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.cart-item-qty input {
    width: 70px;
    padding: .4rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-align: center;
    font-size: .9rem;
}

.cart-item-subtotal {
    font-weight: 600;
    color: #2e7d32;
    min-width: 80px;
    text-align: right;
}

.cart-item-remove {
    color: #d32f2f;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: .25rem;
}

.cart-summary {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.cart-summary .summary-row {
    display: flex;
    justify-content: space-between;
    padding: .5rem 0;
    font-size: .95rem;
}
.cart-summary .summary-row.total {
    border-top: 2px solid #eee;
    margin-top: .5rem;
    padding-top: .75rem;
    font-size: 1.15rem;
    font-weight: 700;
}

/* ---------- Checkout ---------- */
.checkout-container { max-width: 700px; margin: 0 auto; }

.checkout-section {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.checkout-section h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid #f0f0f0;
}

/* ---------- Forms ---------- */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: .9rem;
    font-weight: 500;
    margin-bottom: .3rem;
    color: #444;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: .65rem .75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: .95rem;
    font-family: inherit;
    transition: border-color .2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #2e7d32;
    outline: none;
    box-shadow: 0 0 0 3px rgba(46,125,50,.1);
}

.form-group textarea { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group .help-text { font-size: .8rem; color: #888; margin-top: .25rem; }
.form-group .error-text { font-size: .8rem; color: #d32f2f; margin-top: .25rem; }

.radio-group { display: flex; gap: 1rem; flex-wrap: wrap; }
.radio-group label {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-weight: 400;
    cursor: pointer;
    padding: .5rem .75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    transition: all .2s;
}
.radio-group label:has(input:checked) {
    border-color: #2e7d32;
    background: #f1f8e9;
}
.radio-group input[type="radio"] { accent-color: #2e7d32; }

/* ---------- Flash Messages / Alerts ---------- */
.alert {
    padding: .75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: .9rem;
}
.alert-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.alert-error { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }
.alert-warning { background: #fff8e1; color: #f57f17; border: 1px solid #ffecb3; }
.alert-info { background: #e3f2fd; color: #1565c0; border: 1px solid #bbdefb; }

/* ---------- Order Confirmation ---------- */
.confirmation-box {
    text-align: center;
    background: #fff;
    border-radius: 12px;
    padding: 2.5rem 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    max-width: 600px;
    margin: 0 auto;
}

.confirmation-box .check-icon {
    width: 64px;
    height: 64px;
    background: #e8f5e9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 2rem;
    color: #2e7d32;
}

.confirmation-box h1 { font-size: 1.5rem; margin-bottom: .5rem; }
.confirmation-box .order-number { font-size: 1.2rem; color: #2e7d32; font-weight: 600; margin-bottom: 1.5rem; }

.order-detail-table {
    width: 100%;
    text-align: left;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
}
.order-detail-table th,
.order-detail-table td {
    padding: .6rem .75rem;
    border-bottom: 1px solid #f0f0f0;
    font-size: .9rem;
}
.order-detail-table th { color: #888; font-weight: 500; }

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    justify-content: center;
    gap: .25rem;
    padding: 1.5rem 0;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    padding: .5rem .85rem;
    border-radius: 6px;
    font-size: .9rem;
    border: 1px solid #ddd;
    color: #333;
    transition: all .2s;
}
.pagination a:hover { background: #e8f5e9; border-color: #2e7d32; text-decoration: none; }
.pagination .active { background: #2e7d32; color: #fff; border-color: #2e7d32; }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* ---------- Farmer CTA Banner ---------- */
.farmer-cta {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    padding: 3rem 1rem;
    margin-top: 2rem;
}

.farmer-cta-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 2.5rem;
}

.farmer-cta-content {
    flex: 1;
}

.farmer-cta-content h2 {
    font-size: 1.8rem;
    color: #1b5e20;
    margin-bottom: .75rem;
}

.farmer-cta-content > p {
    font-size: 1.05rem;
    color: #333;
    margin-bottom: 1.5rem;
    line-height: 1.7;
}

.farmer-cta-steps {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.cta-step {
    display: flex;
    align-items: center;
    gap: .6rem;
    background: #fff;
    padding: .75rem 1rem;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    font-size: .9rem;
    color: #333;
    line-height: 1.4;
}

.cta-step-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.farmer-cta-image {
    flex: 0 0 260px;
}

.farmer-cta-image img {
    width: 100%;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,.12);
}

/* ---------- Footer ---------- */
.site-footer {
    background: #263238;
    color: rgba(255,255,255,.7);
    padding: 2rem 1rem;
    margin-top: 2rem;
    font-size: .85rem;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1.5rem;
}

.footer-brand { display: flex; flex-direction: column; align-items: flex-start; }
.footer-logo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin-bottom: .75rem;
    border: 2px solid rgba(255,255,255,.15);
}
.footer-col h4 { color: #fff; margin-bottom: .5rem; font-size: .95rem; }
.footer-col a { color: rgba(255,255,255,.7); }
.footer-col a:hover { color: #fff; }
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: .3rem; }

.footer-bottom {
    max-width: 1200px;
    margin: 1.5rem auto 0;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,.1);
    text-align: center;
    font-size: .8rem;
}

/* ---------- Breadcrumb ---------- */
.breadcrumb {
    padding: .75rem 0;
    font-size: .85rem;
    color: #888;
}
.breadcrumb a { color: #666; }
.breadcrumb a:hover { color: #2e7d32; }
.breadcrumb .separator { margin: 0 .35rem; }

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #888;
}
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; opacity: .3; }
.empty-state h3 { margin-bottom: .5rem; color: #666; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .menu-toggle { display: block; }

    .header-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0; right: 0;
        background: #2e7d32;
        flex-direction: column;
        padding: .5rem 1rem 1rem;
        box-shadow: 0 4px 8px rgba(0,0,0,.2);
    }
    .header-nav.open { display: flex; }
    .header-nav a { padding: .6rem .75rem; }

    .site-logo-img { width: 34px; height: 34px; }

    .hero-logo { max-width: 200px; }
    .hero h1 { font-size: 1.4rem; }
    .search-bar { flex-direction: column; }

    .farmer-cta-inner { flex-direction: column; text-align: center; gap: 1.5rem; }
    .farmer-cta-content h2 { font-size: 1.4rem; }
    .farmer-cta-steps { justify-content: center; }
    .farmer-cta-image { flex: 0 0 auto; max-width: 240px; }

    .filter-inner { gap: .4rem; }
    .filter-bar select { max-width: 140px; font-size: .85rem; }

    .produce-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; }
    .card-body { padding: .75rem; }
    .card-title { font-size: .95rem; }
    .card-price { font-size: 1.05rem; }

    .listing-attributes { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }

    .cart-item { flex-wrap: wrap; }
    .cart-item-subtotal { min-width: auto; }

    .footer-inner { flex-direction: column; }
}

@media (max-width: 480px) {
    .produce-grid { grid-template-columns: 1fr 1fr; gap: .5rem; }
    .card-meta { display: none; }
    .cart-item-image { width: 56px; height: 56px; }
}
