/* ==========================================================================
   Bulk Order Form — Excel-style CSS
   ========================================================================== */

/* ── Google Font ──────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── CSS Variables ────────────────────────────────────────────────────────── */
.bof-wrap {
    --bof-blue:        #71AE49;
    --bof-blue-dark:   #5a9438;
    --bof-blue-light:  #f2f9ec;
    --bof-blue-row:    #e8f5e0;
    --bof-green:       #16a34a;
    --bof-red:         #dc2626;
    --bof-border:      #e2e8f0;
    --bof-bg:          #f8fafc;
    --bof-white:       #ffffff;
    --bof-text:        #1e293b;
    --bof-text-muted:  #64748b;
    --bof-radius:      8px;
    --bof-shadow:      0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --bof-shadow-md:   0 4px 16px rgba(0,0,0,0.10);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--bof-text);
    line-height: 1.5;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 8px;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.bof-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 24px 28px;
    background: linear-gradient(135deg, #4d8230 0%, #71AE49 100%);
    border-radius: var(--bof-radius) var(--bof-radius) 0 0;
    color: #fff;
    flex-wrap: wrap;
}

.bof-header__left {
    flex: 1;
    min-width: 200px;
}

.bof-title {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.3px;
}

.bof-title__icon {
    font-size: 24px;
    line-height: 1;
}

.bof-desc {
    margin: 0;
    font-size: 14px;
    color: #bfdbfe;
}

.bof-header__stats {
    display: flex;
    gap: 20px;
    flex-shrink: 0;
}

.bof-stat {
    text-align: center;
    background: rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 10px 20px;
    min-width: 90px;
    border: 1px solid rgba(255,255,255,0.18);
    backdrop-filter: blur(4px);
}

.bof-stat__value {
    display: block;
    font-size: 26px;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    transition: transform 0.15s ease;
}

.bof-stat__value.bof-bump {
    transform: scale(1.25);
}

.bof-stat__label {
    display: block;
    font-size: 11px;
    color: #c5e8a8;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

/* ── Toolbar ──────────────────────────────────────────────────────────────── */
.bof-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bof-white);
    border-left: 1px solid var(--bof-border);
    border-right: 1px solid var(--bof-border);
    border-bottom: 1px solid var(--bof-border);
    position: sticky;
    top: 32px;         /* account for WP admin bar */
    z-index: 100;
    box-shadow: var(--bof-shadow);
    flex-wrap: wrap;
}

.bof-toolbar__search {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.bof-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--bof-text-muted);
    pointer-events: none;
    line-height: 1;
}

.bof-search {
    width: 100%;
    padding: 9px 12px 9px 36px;
    border: 1.5px solid var(--bof-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    color: var(--bof-text);
    background: var(--bof-bg);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.bof-search:focus {
    border-color: var(--bof-blue);
    box-shadow: 0 0 0 3px rgba(113,174,73,0.12);
    background: var(--bof-white);
}

.bof-toolbar__controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.bof-select {
    padding: 9px 32px 9px 12px;
    border: 1.5px solid var(--bof-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    color: var(--bof-text);
    background: var(--bof-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.bof-select:focus {
    border-color: var(--bof-blue);
    box-shadow: 0 0 0 3px rgba(113,174,73,0.12);
}

/* ── Toggle Switch ────────────────────────────────────────────────────────── */
.bof-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: var(--bof-text-muted);
    white-space: nowrap;
}

.bof-toggle-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.bof-toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    background: #cbd5e1;
    border-radius: 999px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.bof-toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.bof-toggle-checkbox:checked + .bof-toggle-switch {
    background: var(--bof-blue);
}

.bof-toggle-checkbox:checked + .bof-toggle-switch::after {
    transform: translateX(16px);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.bof-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
    outline: none;
}

.bof-btn--ghost {
    background: transparent;
    color: var(--bof-text-muted);
    border: 1.5px solid var(--bof-border);
}

.bof-btn--ghost:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--bof-text);
}

.bof-btn--submit {
    background: linear-gradient(135deg, #5a9438 0%, #71AE49 100%);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 28px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(113,174,73,0.35);
    border: none;
}

.bof-btn--submit:hover:not(:disabled) {
    background: linear-gradient(135deg, #4d8230 0%, #5a9438 100%);
    box-shadow: 0 6px 18px rgba(113,174,73,0.4);
    transform: translateY(-1px);
}

.bof-btn--submit:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(113,174,73,0.3);
}

.bof-btn--submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.bof-btn__spinner {
    display: inline-block;
    animation: bof-spin 0.8s linear infinite;
    font-style: normal;
}

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

/* ── Table Wrapper ────────────────────────────────────────────────────────── */
.bof-table-wrapper {
    max-height: 560px;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid var(--bof-border);
    border-top: none;
    scroll-behavior: smooth;
}

/* Custom scrollbar */
.bof-table-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.bof-table-wrapper::-webkit-scrollbar-track {
    background: #f1f5f9;
}
.bof-table-wrapper::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.bof-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ── Table ────────────────────────────────────────────────────────────────── */
.bof-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: fixed;
}

/* ── Table Head ───────────────────────────────────────────────────────────── */
.bof-table thead tr {
    background: #4d8230;
    position: sticky;
    top: 0;
    z-index: 10;
}

.bof-table thead th {
    padding: 11px 16px;
    text-align: left;
    color: #fff;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    white-space: nowrap;
    border: none;
    user-select: none;
}

.bof-col-num  { width: 54px; text-align: center; }
.bof-col-name { /* fill remaining space */ }
.bof-col-sku  { width: 160px; }
.bof-col-qty  { width: 120px; text-align: center; }

/* ── Table Body Rows ──────────────────────────────────────────────────────── */
.bof-row {
    transition: background-color 0.12s ease;
    cursor: default;
}

.bof-row:nth-child(even) {
    background: #f8fafc;
}

.bof-row:nth-child(odd) {
    background: #ffffff;
}

.bof-row:hover {
    background: #f0f7ff !important;
}

/* Row with quantity > 0 */
.bof-row--active {
    background: var(--bof-blue-row) !important;
}

.bof-row--active:hover {
    background: #c5e8a8 !important;
}

/* Row currently focused (qty input focused) */
.bof-row--focused {
    outline: 2px solid var(--bof-blue);
    outline-offset: -2px;
    position: relative;
    z-index: 1;
}

/* Hidden row (filtered out) */
.bof-row--hidden {
    display: none;
}

.bof-table tbody td {
    padding: 8px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--bof-text);
    vertical-align: middle;
}

.bof-table tbody td.bof-col-num {
    text-align: center;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 500;
}

.bof-sku {
    font-family: 'SFMono-Regular', Consolas, 'Courier New', monospace;
    font-size: 12px;
    color: #475569;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
}

.bof-empty {
    text-align: center;
    padding: 40px !important;
    color: var(--bof-text-muted);
    font-style: italic;
}

/* ── Quantity Input — Excel cell style ────────────────────────────────────── */
.bof-col-qty {
    text-align: center;
}

.bof-qty-input {
    width: 80px;
    padding: 6px 8px;
    border: 1.5px solid transparent;
    border-bottom: 2px solid #cbd5e1;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    text-align: center;
    background: transparent;
    color: var(--bof-text);
    outline: none;
    transition: all 0.15s ease;
    -moz-appearance: textfield;
}

/* Remove spinner arrows (Chrome/Safari) */
.bof-qty-input::-webkit-outer-spin-button,
.bof-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.bof-qty-input:focus {
    border: 1.5px solid var(--bof-blue);
    border-radius: 4px;
    background: rgba(255,255,255,0.95);
    box-shadow: 0 0 0 3px rgba(113,174,73,0.15);
    color: var(--bof-blue);
}

/* Qty input when row is active */
.bof-row--active .bof-qty-input {
    border-bottom-color: var(--bof-blue);
    color: var(--bof-blue);
    font-weight: 700;
}

.bof-row--active .bof-qty-input:focus {
    background: rgba(255,255,255,0.9);
}

/* ── Table Footer Bar ─────────────────────────────────────────────────────── */
.bof-table-footer {
    padding: 8px 16px;
    background: #f8fafc;
    border: 1px solid var(--bof-border);
    border-top: none;
    font-size: 12px;
    color: var(--bof-text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Customer Section ─────────────────────────────────────────────────────── */
.bof-customer-section {
    margin-top: 28px;
    background: var(--bof-white);
    border: 1px solid var(--bof-border);
    border-radius: var(--bof-radius);
    padding: 24px;
    box-shadow: var(--bof-shadow);
}

.bof-section-title {
    margin: 0 0 20px;
    font-size: 15px;
    font-weight: 700;
    color: var(--bof-text);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--bof-border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.bof-section-title::before {
    content: '👤';
}

.bof-customer-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

@media (max-width: 768px) {
    .bof-customer-grid {
        grid-template-columns: 1fr;
    }
}

.bof-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bof-field--full {
    width: 100%;
}

.bof-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--bof-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bof-required {
    color: var(--bof-red);
    margin-left: 2px;
}

.bof-input {
    padding: 10px 14px;
    border: 1.5px solid var(--bof-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    color: var(--bof-text);
    background: var(--bof-bg);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.bof-input:focus {
    border-color: var(--bof-blue);
    box-shadow: 0 0 0 3px rgba(113,174,73,0.12);
    background: var(--bof-white);
}

.bof-input.bof-input--error {
    border-color: var(--bof-red);
    box-shadow: 0 0 0 3px rgba(220,38,38,0.10);
}

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

/* ── Submit Area ──────────────────────────────────────────────────────────── */
.bof-submit-area {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-top: 20px;
    padding: 20px 24px;
    background: var(--bof-white);
    border: 1px solid var(--bof-border);
    border-radius: var(--bof-radius);
    box-shadow: var(--bof-shadow);
    flex-wrap: wrap;
}

.bof-submit-summary {
    font-size: 14px;
    color: var(--bof-text-muted);
    flex: 1;
    min-width: 200px;
}

.bof-submit-summary strong {
    color: var(--bof-blue);
    font-weight: 700;
}

/* ── Message Box ──────────────────────────────────────────────────────────── */
.bof-message {
    margin-top: 16px;
    padding: 14px 20px;
    border-radius: var(--bof-radius);
    font-size: 14px;
    font-weight: 500;
    animation: bof-slide-in 0.25s ease;
}

@keyframes bof-slide-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.bof-message--success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.bof-message--error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
    .bof-header {
        padding: 18px;
        flex-direction: column;
    }

    .bof-header__stats {
        width: 100%;
        justify-content: flex-start;
    }

    .bof-toolbar {
        flex-direction: column;
        align-items: stretch;
        top: 46px;
    }

    .bof-toolbar__controls {
        flex-wrap: wrap;
    }

    .bof-col-sku {
        display: none;
    }

    .bof-table thead th.bof-col-sku,
    .bof-table tbody td.bof-col-sku {
        display: none;
    }

    .bof-submit-area {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .bof-btn--submit {
        width: 100%;
        justify-content: center;
    }

    .bof-stat {
        min-width: 70px;
        padding: 8px 12px;
    }
}

/* ── Product Name Tooltip ─────────────────────────────────────────────────── */

/*
 * Uses position:relative on the wrapper and a CSS-only tooltip bubble.
 * The tooltip is pre-rendered in the DOM (data in data-description attr)
 * so zero extra HTTP requests are made on hover.
 */

.bof-name-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: default;
    max-width: 100%;
}

/* Small "ℹ" indicator to hint that a description is available */
.bof-name-wrap::after {
    content: 'ℹ';
    font-size: 11px;
    color: #94a3b8;
    flex-shrink: 0;
    transition: color 0.15s;
    line-height: 1;
    margin-top: 1px;
}

.bof-name-wrap:hover::after {
    color: var(--bof-blue);
}

/* The tooltip bubble */
.bof-tooltip {
    /* Hidden by default */
    visibility: hidden;
    opacity: 0;
    pointer-events: none;

    /* Positioning: appears above the product name */
    position: absolute;
    bottom: calc(100% + 10px);
    left: 0;
    z-index: 9999;

    /* Size & layout */
    width: 280px;
    max-width: 90vw;
    padding: 10px 14px;

    /* Style */
    background: #1e293b;
    color: #e2e8f0;
    font-size: 12.5px;
    font-weight: 400;
    line-height: 1.55;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.22);
    white-space: normal;
    word-break: break-word;

    /* Smooth fade */
    transition: opacity 0.18s ease, transform 0.18s ease;
    transform: translateY(4px);
}

/* Arrow pointer pointing down */
.bof-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 18px;
    border: 6px solid transparent;
    border-top-color: #1e293b;
}

/* Show on hover */
.bof-name-wrap:hover .bof-tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

/* If the row is near the top of the visible scroll area,
   flip tooltip to appear BELOW instead (avoid clipping) */
.bof-table-wrapper tr:nth-child(-n+3) .bof-tooltip {
    bottom: auto;
    top: calc(100% + 10px);
    transform: translateY(-4px);
}

.bof-table-wrapper tr:nth-child(-n+3) .bof-tooltip::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #1e293b;
}

.bof-table-wrapper tr:nth-child(-n+3) .bof-name-wrap:hover .bof-tooltip {
    transform: translateY(0);
}

/* On mobile: full-width tooltip, left-edge aligned */
@media (max-width: 600px) {
    .bof-tooltip {
        width: 220px;
        font-size: 12px;
    }
}

/* ── reCAPTCHA v3 ─────────────────────────────────────────────────────────── */

/*
 * Hide the default floating reCAPTCHA badge.
 * Google allows this as long as we display the required legal notice in the UI.
 * See: https://developers.google.com/recaptcha/docs/faq#id-like-to-hide-the-recaptcha-badge.-what-is-allowed
 */
.grecaptcha-badge {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Legal notice shown below the submit button when reCAPTCHA is active */
.bof-recaptcha-notice {
    margin: 10px 0 0;
    font-size: 11.5px;
    color: #94a3b8;
    text-align: right;
    line-height: 1.5;
}

.bof-recaptcha-notice a {
    color: #64748b;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.bof-recaptcha-notice a:hover {
    color: var(--bof-blue);
}

