/* =============================================================================
   Quote Manager – Frontend Styles
   All classes are prefixed with .qm- to avoid conflicts.
   Override freely in your theme or Elementor custom CSS.
   ============================================================================= */

/* ---- Basket table ---- */
.qm-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
}

.qm-table th,
.qm-table td {
    padding: 12px 16px;
    border: 1px solid #e5e5e5;
    text-align: left;
    vertical-align: middle;
}

/* Product column grows; SKU / Qty / Remove shrink to content */
.qm-table th:first-child,
.qm-table td:first-child {
    width: 100%;
}

.qm-table th:not(:first-child),
.qm-table td:not(:first-child) {
    width: 1%;
    white-space: nowrap;
}

.qm-table th {
    background: #f7f7f7;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.qm-empty {
    color: #888;
    font-style: italic;
}

.qm-table--hoverable tbody tr {
    transition: background-color 0.2s ease-in-out;
}

.qm-table--hoverable tbody tr:hover {
    background-color: #f5f5f5;
}

/* ---- Qty input ---- */
input[type=number].qm-qty-input {
    width: 88px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
}

/* ---- Remove button ---- */
.qm-remove-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #c0392b;
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}

.qm-remove-btn:hover {
    background: #fdf2f2;
}

.qm-remove-btn__icon {
    display: inline-flex;
    align-items: center;
    transition: opacity 0.15s;
}

.qm-remove-btn__loader {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}

.qm-remove-btn.qm-removing {
    pointer-events: none;
}

.qm-remove-btn.qm-removing .qm-remove-btn__icon {
    opacity: 0;
}

.qm-remove-btn.qm-removing .qm-remove-btn__loader {
    opacity: 1;
}

.qm-remove-btn.qm-removing .qm-remove-btn__loader i,
.qm-remove-btn.qm-removing .qm-remove-btn__loader svg {
    animation: qm-spin 0.65s linear infinite;
}

/* ---- Edit button (custom basket items) ---- */
.qm-cp-edit-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #555;
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.qm-cp-edit-btn:hover {
    background: #f0f0f0;
    color: #1a1a1a;
}

.qm-cp-edit-btn__icon {
    display: inline-flex;
    align-items: center;
}

.qm-cp-edit-btn--small {
    font-size: 0.85rem;
    padding: 2px 6px;
}

/* ---- Contact form ---- */
#qm-form-wrap {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid #e5e5e5;
}

#qm-form-wrap.qm-form-wrap--no-separator {
    border-top: none;
}

#qm-form-wrap h3 {
    margin-bottom: 1.25rem;
}

.qm-form-group {
    margin-bottom: 1.1rem;
}

.qm-form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.qm-form-group input,
.qm-form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.qm-form-group input:focus,
.qm-form-group textarea:focus {
    border-color: #555;
    outline: none;
}

/* ---- Submit button ---- */
.qm-btn {
    display: inline-block;
    padding: 12px 28px;
    background: #1a1a1a;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    margin-top: 0.5rem;
}

.qm-btn:hover {
    background: #333;
}

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

/* ---- Add-to-quote quantity wrapper ---- */
.qm-atq-wrap {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
}

.qm-atq-wrap--stacked {
    display: flex; /* block-level so full-width button works relative to parent */
    flex-direction: column;
    align-items: flex-start;
}

/* default gap: qty-group → button (layout-specific margins so Elementor can override cleanly) */
.qm-atq-wrap--inline .qm-atq-qty-wrap  { margin-right: 8px; }
.qm-atq-wrap--stacked .qm-atq-qty-wrap { margin-bottom: 8px; }

.qm-atq-qty-wrap {
    display: inline-flex;
    align-items: center;
}

.qm-atq-qty-label {
    white-space: nowrap;
    margin-right: 6px; /* default gap: label → input */
}

.qm-atq-qty {
    width: 64px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    font-size: 1rem;
    box-sizing: border-box;
}

/* ---- Add-to-quote button (on listing pages) ---- */
.add-to-quote-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Inner content wrapper — sizes the button; fades out during loading/success */
.add-to-quote-btn__content {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    transition: opacity 0.15s;
}

/* Spinner and check are absolute overlays, invisible by default */
.add-to-quote-btn__spinner,
.add-to-quote-btn__check {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}

/* Spinner icon sizing */
.add-to-quote-btn__spinner i,
.add-to-quote-btn__spinner svg {
    font-size: 1.1em;
    width: 1.1em;
    height: 1.1em;
}

/* Check icon sizing */
.add-to-quote-btn__check i,
.add-to-quote-btn__check svg {
    font-size: 1.1em;
    width: 1.1em;
    height: 1.1em;
}

@keyframes qm-spin {
    to { transform: rotate(360deg); }
}

/* Loading state: disable pointer events, fade content out, show spinner */
.add-to-quote-btn.qm-loading {
    pointer-events: none;
}

.add-to-quote-btn.qm-loading .add-to-quote-btn__content {
    opacity: 0;
}

.add-to-quote-btn.qm-loading .add-to-quote-btn__spinner {
    opacity: 1;
}

.add-to-quote-btn.qm-loading .add-to-quote-btn__spinner i,
.add-to-quote-btn.qm-loading .add-to-quote-btn__spinner svg {
    animation: qm-spin 0.65s linear infinite;
}

/* Success state: fade content out, show checkmark */
.add-to-quote-btn.qm-added .add-to-quote-btn__content {
    opacity: 0;
}

.add-to-quote-btn.qm-added .add-to-quote-btn__check {
    opacity: 1;
}

/* ---- Counter badge (place .qm-count anywhere in your header) ---- */
.qm-count {
    display: inline-block;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    background: #1a1a1a;
    color: #fff;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
    padding: 0 5px;
}

/* ---- Toast notification ---- */
#qm-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    z-index: 99999;
    display: none;
    max-width: 320px;
}

#qm-toast.qm-toast--success {
    background: #27ae60;
    color: #fff;
}

#qm-toast.qm-toast--error {
    background: #c0392b;
    color: #fff;
}

/* ---- Inline notice (basket page) ---- */
.qm-notice {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.qm-notice--success {
    background: #eafaf1;
    color: #1e8449;
    border: 1px solid #a9dfbf;
}

.qm-notice--error {
    background: #fdf2f2;
    color: #c0392b;
    border: 1px solid #f5b7b1;
}

/* ---- Success message post-submit ---- */
.qm-success-msg {
    padding: 24px;
    background: #eafaf1;
    border: 1px solid #a9dfbf;
    border-radius: 6px;
    color: #1e8449;
    font-size: 1.05rem;
    font-weight: 500;
    text-align: center;
}

/* ---- Mini cart ---- */
.qm-mini-cart {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
}

.qm-mini-cart__trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    line-height: 1;
}

.qm-mini-cart__trigger:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* Icon wrapper is the positioning anchor for the badge */
.qm-mini-cart__icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.qm-mini-cart__icon-wrap svg {
    display: block;
    width: 1em;
    height: 1em;
}

/* Badge: hidden by default, overlaid on icon when basket has items.
   Three-class specificity (0-3-0) ensures position: absolute beats any
   single-class theme or Elementor reset. */
.qm-mini-cart .qm-mini-cart__icon-wrap .qm-count {
    display: none;
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    line-height: 18px;
    font-size: 0.65rem;
    font-weight: 700;
    background: #e74c3c;
    color: #fff;
    border-radius: 9px;
    text-align: center;
    pointer-events: none;
}

.qm-mini-cart .qm-mini-cart__icon-wrap .qm-count.qm-count--has-items {
    display: block;
}

.qm-mini-cart__dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 9999;
}

.qm-mini-cart--open .qm-mini-cart__dropdown {
    display: block;
}

.qm-mini-cart__items {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 320px;
    overflow-y: auto;
}

.qm-mini-cart__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.qm-mini-cart__img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 3px;
    flex-shrink: 0;
}

.qm-mini-cart__item-details {
    flex: 1;
    min-width: 0;
}

.qm-mini-cart__item-name {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 5px;
}

.qm-mini-cart__qty {
    width: 58px !important;
    padding: 4px 6px !important;
    font-size: 0.875rem !important;
}

.qm-mini-cart__empty {
    padding: 20px 16px;
    margin: 0;
    color: #888;
    font-style: italic;
    text-align: center;
}

.qm-mini-cart__footer {
    padding: 12px 16px;
    border-top: 1px solid #e5e5e5;
}

.qm-mini-cart__view-btn {
    display: block;
    text-align: center;
    padding: 10px 16px;
    background: #1a1a1a;
    color: #fff !important;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background 0.2s;
}

.qm-mini-cart__view-btn:hover {
    background: #333;
    color: #fff !important;
}

/* ---- Admin meta box tables ---- */
.qm-admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.qm-admin-table th,
.qm-admin-table td {
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    text-align: left;
}

.qm-admin-table th {
    background: #f9f9f9;
    width: 160px;
}

.qm-products-table {
    width: 100%;
    border-collapse: collapse;
}

.qm-products-table th {
    background: #f1f1f1;
}

.qm-products-table th,
.qm-products-table td {
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
}

/* ---- Admin status badges (wp-admin list table) ---- */
.qm-status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.qm-status-qm-pending  { background: #fef9e7; color: #b7950b; }
.qm-status-qm-reviewed { background: #eaf4fb; color: #1a6d9e; }
.qm-status-qm-sent     { background: #eaf7fb; color: #117a65; }
.qm-status-qm-accepted { background: #eafaf1; color: #1e8449; }
.qm-status-qm-declined { background: #fdf2f2; color: #c0392b; }
