/* =============================================
   E&L Growers — Preorder Styles
   Mobile-first farmers market ordering
   ============================================= */

.elg-preorder-wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 12px;
}

/* =============================================
   Step 1: Market & Week Selection
   ============================================= */
.elg-preorder-header {
    text-align: center;
    margin-bottom: 24px;
}

.elg-preorder-header h2 {
    font-size: 24px;
    margin: 0 0 8px;
    color: #2d5016;
}

.elg-preorder-header p {
    color: #666;
    font-size: 15px;
    margin: 0;
}

.elg-preorder-selectors {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.elg-preorder-field label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: #555;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.elg-preorder-field select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 16px;
    background: #fff;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

.elg-preorder-login-prompt {
    text-align: center;
    padding: 48px 24px;
    background: linear-gradient(135deg, #f0f7e8, #e8f4d8);
    border-radius: 12px;
}

.elg-preorder-login-prompt h2 {
    font-size: 28px;
    margin-bottom: 12px;
}

.elg-preorder-auth-links {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

/* =============================================
   Step 2: Shopping
   ============================================= */
.elg-preorder-shop-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.elg-po-back {
    background: none;
    border: none;
    color: #4a8c1c;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 0;
    font-weight: 500;
}

.elg-po-back:hover {
    color: #2d5016;
    text-decoration: underline;
}

.elg-po-context {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: #666;
}

.elg-po-context span {
    background: #f5f5f5;
    padding: 4px 10px;
    border-radius: 12px;
}

/* Category filter tabs */
.elg-po-categories {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 4px 0 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.elg-po-categories::-webkit-scrollbar { display: none; }

.elg-po-cat-btn {
    white-space: nowrap;
    padding: 6px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    color: #555;
    flex-shrink: 0;
}

.elg-po-cat-btn:hover {
    border-color: #4a8c1c;
    color: #4a8c1c;
}

.elg-po-cat-btn.active {
    background: #4a8c1c;
    color: #fff;
    border-color: #4a8c1c;
}

/* Product list container */
.elg-po-products {
    display: block;
    padding-bottom: 100px; /* Space for cart bar + GP footer clearance */
}

.elg-po-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px;
    color: #999;
}

.elg-spin {
    animation: elg-spin 1s linear infinite;
}

@keyframes elg-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.elg-po-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 24px;
    color: #888;
}

/* Product card */
.elg-po-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    position: relative;
}

.elg-po-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.elg-po-card.in-cart {
    border-color: #4a8c1c;
    box-shadow: 0 0 0 2px rgba(74,140,28,0.2);
}

.elg-po-card.sold-out {
    opacity: 0.5;
    pointer-events: none;
}

.elg-po-card-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: #f5f5f5;
    display: block;
}

.elg-po-card-image-placeholder {
    width: 100%;
    aspect-ratio: 1;
    background: linear-gradient(135deg, #e8f4d8, #d4ecc0);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
}

.elg-po-card-body {
    padding: 10px 12px;
}

.elg-po-card-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 0 4px;
    line-height: 1.2;
}

.elg-po-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.elg-po-card-price {
    font-size: 15px;
    font-weight: 700;
    color: #4a8c1c;
}

.elg-po-card-unit {
    font-size: 11px;
    color: #999;
    font-weight: 400;
}

.elg-po-card-remaining {
    font-size: 11px;
    color: #999;
}

.elg-po-card-remaining.low {
    color: #e65100;
    font-weight: 600;
}

/* In-cart badge */
.elg-po-card-cart-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #4a8c1c;
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

/* =============================================
   Floating Cart Bar
   ============================================= */
.elg-po-cart-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 2px solid #4a8c1c;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 9999;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
}

.elg-po-cart-summary {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.elg-po-cart-count {
    font-size: 13px;
    color: #666;
}

.elg-po-cart-total {
    font-size: 20px;
    font-weight: 700;
    color: #2d5016;
}

/* =============================================
   Step 3: Checkout
   ============================================= */
.elg-po-review-items {
    margin-bottom: 20px;
}

.elg-po-review-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.elg-po-review-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.elg-po-review-item-name {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.elg-po-review-item-meta {
    font-size: 12px;
    color: #888;
}

.elg-po-review-item-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.elg-po-review-item-total {
    font-weight: 600;
    font-size: 15px;
    color: #333;
    min-width: 60px;
    text-align: right;
}

.elg-po-review-remove {
    background: none;
    border: none;
    color: #ccc;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
}

.elg-po-review-remove:hover {
    color: #c62828;
}

/* Order summary */
.elg-po-order-summary {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.elg-po-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
    color: #555;
}

.elg-po-summary-row small {
    color: #999;
    font-size: 12px;
}

.elg-po-credit-row {
    color: #4a8c1c;
}

.elg-po-total-row {
    border-top: 2px solid #ddd;
    margin-top: 8px;
    padding-top: 12px;
    font-size: 18px;
    color: #333;
}

/* Payment options */
.elg-po-payment-options {
    margin-bottom: 20px;
}

.elg-po-payment-options > label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: #555;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.elg-po-payment-radios {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.elg-po-payment-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 2px solid #eee;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.elg-po-payment-option:has(input:checked) {
    border-color: #4a8c1c;
    background: #f7faf3;
}

.elg-po-payment-option input[type="radio"] {
    accent-color: #4a8c1c;
}

.elg-po-pay-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.elg-po-pay-label strong {
    font-size: 14px;
    color: #333;
}

.elg-po-pay-label small {
    font-size: 12px;
    color: #888;
}

/* Stripe card element */
.elg-po-stripe-wrap {
    margin-bottom: 20px;
}

.elg-po-stripe-wrap label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: #555;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

#elg-stripe-card-element {
    padding: 12px 14px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
}

/* Notes */
.elg-po-notes-wrap {
    margin-bottom: 20px;
}

.elg-po-notes-wrap label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: #555;
    margin-bottom: 6px;
}

.elg-po-notes-wrap textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

/* Status messages */
.elg-po-status {
    text-align: center;
    padding: 12px;
    margin-top: 12px;
    border-radius: 8px;
    font-size: 14px;
}

.elg-po-status.error {
    background: #FFEBEE;
    color: #C62828;
}

.elg-po-status.success {
    background: #E8F5E9;
    color: #2E7D32;
}

.elg-po-status.loading {
    background: #FFF8E1;
    color: #F57F17;
}

/* =============================================
   Step 4: Confirmation
   ============================================= */
.elg-po-confirmation {
    text-align: center;
    padding: 40px 20px;
}

.elg-po-confirm-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.elg-po-confirmation h2 {
    font-size: 28px;
    color: #2d5016;
    margin: 0 0 8px;
}

.elg-po-confirmation > p {
    color: #666;
    font-size: 16px;
    margin-bottom: 24px;
}

.elg-po-confirm-details {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
    text-align: left;
    font-size: 14px;
    color: #555;
}

.elg-po-confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* =============================================
   Product Detail Popup
   ============================================= */
.elg-product-popup-content {
    max-width: 440px;
    padding: 0;
    overflow: hidden;
}

.elg-product-popup-image {
    width: 100%;
    aspect-ratio: 4/3;
    background: #f5f5f5;
    overflow: hidden;
}

.elg-product-popup-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.elg-product-popup-info {
    padding: 20px;
}

.elg-product-popup-info h3 {
    font-size: 20px;
    margin: 0 0 8px;
    color: #333;
}

#elg-popup-desc {
    color: #666;
    font-size: 14px;
    margin: 0 0 16px;
    line-height: 1.5;
}

.elg-popup-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.elg-popup-price {
    font-size: 22px;
    font-weight: 700;
    color: #4a8c1c;
}

.elg-popup-remaining {
    font-size: 13px;
    color: #888;
}

.elg-popup-qty-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 16px;
}

.elg-popup-qty-row .elg-qty-btn {
    width: 44px;
    height: 44px;
    font-size: 22px;
}

.elg-popup-qty-row .elg-qty-input {
    width: 64px;
    height: 44px;
    font-size: 18px;
}

/* =============================================
   Account Page — Order History Styles
   ============================================= */
.elg-order-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.elg-order-row {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.elg-order-row:last-child { border-bottom: none; }

.elg-order-row-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.elg-order-row-main strong {
    font-size: 14px;
}

.elg-order-market {
    font-size: 12px;
    color: #888;
    margin-left: 8px;
}

.elg-order-row-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.elg-order-total {
    font-weight: 600;
    font-size: 14px;
}

.elg-order-status-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 8px;
    letter-spacing: 0.3px;
}

.elg-ostatus-pending .elg-order-status-badge { background: #FFF8E1; color: #F57F17; }
.elg-ostatus-confirmed .elg-order-status-badge { background: #E3F2FD; color: #1565C0; }
.elg-ostatus-ready .elg-order-status-badge { background: #E8F5E9; color: #2E7D32; }
.elg-ostatus-picked_up .elg-order-status-badge { background: #E8F5E9; color: #2E7D32; }
.elg-ostatus-cancelled .elg-order-status-badge { background: #FFEBEE; color: #C62828; }

.elg-order-row-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: #999;
}

.elg-cancel-order-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.elg-cancel-order-btn:hover { color: #c62828; }

/* =============================================
   Shared button styles (extend elg-public.css)
   ============================================= */
.elg-btn-large {
    padding: 16px 32px !important;
    font-size: 16px !important;
}

.elg-btn-full {
    width: 100%;
}

/* =============================================
   Responsive
   ============================================= */
@media (min-width: 480px) {
    .elg-preorder-selectors {
        flex-direction: row;
    }

    .elg-preorder-field {
        flex: 1;
    }
}

@media (max-width: 400px) {
    .elg-po-products {
        grid-template-columns: 1fr;
    }

    .elg-po-confirm-actions {
        flex-direction: column;
    }
}

/* ===========================================
   List Format Preorder (replaces card grid)
   =========================================== */
.elg-po-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 100%;
}

.elg-po-list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    transition: background 0.15s;
    gap: 12px;
}

.elg-po-list-row:hover { background: #fafafa; }
.elg-po-list-row.in-cart { background: #f0faf0; border-left: 3px solid var(--elg-primary, #D91A1A); }
.elg-po-list-row.sold-out { opacity: 0.5; }

.elg-po-list-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.elg-po-list-thumb {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    cursor: pointer;
}

.elg-po-list-thumb-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.elg-po-list-details {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    flex-wrap: wrap;
    min-width: 0;
}

.elg-po-list-name {
    font-weight: 600;
    font-size: 15px;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
}

.elg-po-list-name:hover { color: var(--elg-primary, #D91A1A); text-decoration: underline; }

.elg-po-list-price {
    font-weight: 700;
    color: var(--elg-primary, #D91A1A);
    font-size: 14px;
    white-space: nowrap;
}

.elg-po-list-unit { font-weight: 400; color: #888; font-size: 12px; }

.elg-po-list-remaining {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
    flex-shrink: 0;
}
.elg-po-list-remaining.low { color: #c62828; font-weight: 600; }

.elg-po-list-qty {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
}

.elg-po-list-minus,
.elg-po-list-plus {
    width: 34px;
    height: 34px;
    border: 1px solid #ccc;
    background: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    transition: all 0.15s;
}

.elg-po-list-minus { border-radius: 4px 0 0 4px; }
.elg-po-list-plus { border-radius: 0 4px 4px 0; }
.elg-po-list-minus:hover, .elg-po-list-plus:hover { background: #f0f0f0; }

.elg-po-list-qty-input {
    width: 48px;
    height: 34px;
    text-align: center;
    border: 1px solid #ccc;
    border-left: none;
    border-right: none;
    font-size: 15px;
    font-weight: 600;
    -moz-appearance: textfield;
}
.elg-po-list-qty-input::-webkit-outer-spin-button,
.elg-po-list-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.elg-po-list-soldout { font-size: 12px; color: #999; font-style: italic; }

/* Make product grid use full width */
.elg-po-products { width: 100%; }

/* Responsive: stack on mobile */
@media (max-width: 600px) {
    .elg-po-list-details {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
    .elg-po-list-row {
        padding: 10px 12px;
    }
    .elg-po-list-thumb {
        width: 40px;
        height: 40px;
    }
}

/* Specials / Promotions */
.elg-po-list-row.is-special {
    background: linear-gradient(135deg, #fff8e1 0%, #ffffff 100%);
    border-left: 3px solid #ff6f00;
}
.elg-special-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: #e65100;
    background: #fff3e0;
    padding: 1px 8px;
    border-radius: 10px;
    white-space: nowrap;
}
.elg-special-price {
    color: #c62828 !important;
    font-weight: 700;
}
.elg-original-price {
    color: #999;
    font-weight: 400;
    font-size: 0.9em;
    text-decoration: line-through;
}
