/* MightyInks Bulk Studio - Frontend Styles v1.4.0 */

/* ===== Toggle Switch (first row inside variations table) ===== */
.mibs-toggle-row {
    border-top: none !important;
}

.mibs-toggle-row > td {
    text-align: center !important;
    padding: 24px 0 20px 0 !important;
    display: flex !important;
    justify-content: center !important;
    border-top: none !important;
    border-bottom: none !important;
}

/* In bulk mode, remove the top padding since table display:block already provides it */
body.mibs-bulk-mode .mibs-toggle-row > td {
    padding: 0 0 16px 0 !important;
}

.mibs-toggle-container {
    display: inline-flex;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    overflow: hidden;
}

.mibs-toggle-btn {
    padding: 8px 24px;
    font-size: 13px;
    font-weight: 600;
    color: #999;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    border-radius: 0;
}

.mibs-toggle-btn.active {
    color: #fff;
    background: var(--wd-primary-color, #0093b0);
}

.mibs-toggle-btn:not(.active):hover {
    color: #ddd;
    background: rgba(255,255,255,0.03);
}

/* ===== Bulk content row (inside table, padding to match swatch rows) ===== */
.mibs-bulk-row > td {
    padding: 0 !important;
    border-bottom: none !important;
}

.mibs-bulk-container {
    display: none;
    animation: mibs-fadeIn 0.3s ease;
    width: 100%;
    max-width: 100%;
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
}

/* Ensure the variations table never overflows its container */
table.variations {
    width: 100% !important;
    max-width: 100% !important;
}

/* In bulk mode, make the table display as block so it respects container width */
body.mibs-bulk-mode table.variations {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 24.375px 12px !important;
}

body.mibs-bulk-mode table.variations > tbody {
    display: block !important;
    width: 100% !important;
}

body.mibs-bulk-mode table.variations > tbody > tr {
    display: block !important;
    width: 100% !important;
}

body.mibs-bulk-mode table.variations > tbody > tr > td {
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.mibs-bulk-container.active {
    display: block;
}

@keyframes mibs-fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Color Selection Section ===== */
.mibs-color-section {
    margin-bottom: 18px;
}

.mibs-color-section-label {
    font-size: 14px;
    font-weight: 600;
    color: #ccc;
    margin-bottom: 10px;
    display: block;
}

.mibs-color-swatches {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.mibs-color-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 6px 4px;
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    background: rgba(255,255,255,0.03);
    min-width: 0;
}

.mibs-color-swatch:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(0, 147, 176, 0.3);
}

.mibs-color-swatch.selected {
    border-color: var(--wd-primary-color, #0093b0);
    background: rgba(0, 147, 176, 0.08);
}

.mibs-color-swatch-img {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
}

.mibs-color-swatch-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mibs-color-swatch-img-placeholder {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    background: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #666;
}

.mibs-color-swatch-name {
    font-size: 11px;
    color: #999;
    text-align: center;
    line-height: 1.2;
    max-width: 68px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mibs-color-swatch.selected .mibs-color-swatch-name {
    color: #fff;
}

/* ===== Bulk Matrix (CSS Grid for perfect alignment) ===== */
.mibs-matrix-wrapper {
    overflow-x: auto;
    margin-top: 15px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.08);
    max-width: 100%;
}

.mibs-matrix-grid {
    display: grid;
}

.mibs-matrix-grid .mibs-grid-head,
.mibs-matrix-grid .mibs-grid-row,
.mibs-matrix-grid .mibs-grid-foot {
    display: grid;
    grid-template-columns: minmax(80px, 160px) repeat(var(--mibs-size-count, 6), minmax(0, 1fr)) minmax(45px, 70px);
}

.mibs-matrix-grid .mibs-grid-head > div {
    background: rgba(255,255,255,0.04);
    padding: 10px 4px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #ccc;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.mibs-matrix-grid .mibs-grid-head > div:first-child {
    text-align: left;
    padding-left: 8px;
}

.mibs-matrix-grid .mibs-grid-row {
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.mibs-matrix-grid .mibs-grid-row:hover {
    background: rgba(255,255,255,0.02);
}

.mibs-matrix-grid .mibs-grid-row > div {
    padding: 8px 4px;
    text-align: center;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.mibs-matrix-grid .mibs-grid-row > div:first-child {
    text-align: left;
    flex-direction: row;
    gap: 8px;
    padding-left: 8px;
    align-items: center;
    justify-content: flex-start;
}

/* Stock count below input */
.mibs-matrix-stock {
    display: block;
    font-size: 10px;
    color: #888;
    margin-top: 3px;
    line-height: 1;
}

.mibs-matrix-stock.low {
    color: #ff9800;
}

.mibs-matrix-stock.out {
    color: #f44336;
}

.mibs-matrix-qty-input {
    width: 50px;
    padding: 6px 4px;
    text-align: center;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    outline: none;
    transition: border-color 0.2s;
    -moz-appearance: textfield;
}

.mibs-matrix-qty-input::-webkit-outer-spin-button,
.mibs-matrix-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.mibs-matrix-qty-input:focus {
    border-color: var(--wd-primary-color, #0093b0);
    background: rgba(0, 147, 176, 0.05);
}

.mibs-matrix-qty-input:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.mibs-matrix-row-total {
    font-weight: 700;
    color: var(--wd-primary-color, #0093b0);
    font-size: 14px;
}

.mibs-matrix-row-total.has-qty {
    color: #fff;
}

.mibs-matrix-row-out-of-stock {
    color: #f44336;
    font-size: 11px;
    font-style: italic;
}

/* Footer row (Total per Size) */
.mibs-matrix-grid .mibs-grid-foot > div {
    font-weight: 700;
    color: #fff;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 10px 4px;
    text-align: center;
    font-size: 13px;
}

.mibs-matrix-grid .mibs-grid-foot > div:first-child {
    text-align: left;
    color: #ccc;
    font-weight: 600;
    padding-left: 8px;
}

/* Grand Total Bar */
.mibs-grand-total-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 8px;
    margin-top: 15px;
    background: rgba(0, 147, 176, 0.08);
    border: 1px solid rgba(0, 147, 176, 0.15);
    border-radius: 8px;
}

.mibs-grand-total-label {
    font-size: 15px;
    font-weight: 600;
    color: #ccc;
}

.mibs-grand-total-value {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
}

.mibs-grand-total-items {
    font-size: 13px;
    color: #888;
    margin-left: 8px;
}

/* ===== Add Bulk to Cart button (matches Mighty Studio button) ===== */
.mibs-add-bulk-btn {
    background: var(--wd-primary-color, #0093b0) !important;
    color: #fff !important;
    border: none !important;
    padding: 20px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    border-radius: 12px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-transform: uppercase !important;
    letter-spacing: 0.3px !important;
    display: block !important;
    width: 100% !important;
    text-align: center !important;
    margin-top: 15px !important;
    line-height: 32px !important;
    box-shadow: none !important;
    text-indent: 0 !important;
    min-height: 72px !important;
}

.mibs-add-bulk-btn:hover {
    filter: brightness(1.1);
}

.mibs-add-bulk-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mibs-add-bulk-btn.fpd-pending {
    background: #555 !important;
}

/* ===== Mode: hide single order elements when in bulk mode ===== */
/* Hide the color/size swatch rows */
body.mibs-bulk-mode .variations_form .variations > tbody > tr:not(.mibs-toggle-row):not(.mibs-bulk-row) {
    display: none !important;
}

/* Hide the quantity input only */
body.mibs-bulk-mode .variations_form .quantity {
    display: none !important;
}

/* Hide the Add to Cart button only */
body.mibs-bulk-mode .variations_form .single_add_to_cart_button {
    display: none !important;
}

/* Hide reset variations */
body.mibs-bulk-mode .variations_form .reset_variations {
    display: none !important;
}

/* Hide the single variation price display (but NOT the whole wrap — Mighty Studio button lives in there) */
body.mibs-bulk-mode .variations_form .single_variation_wrap > .woocommerce-variation {
    display: none !important;
}

/* Make the add-to-cart wrapper show the Mighty Studio button properly */
body.mibs-bulk-mode .variations_form .woocommerce-variation-add-to-cart {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
}

body.mibs-bulk-mode .variations_form .woocommerce-variation-add-to-cart .fpd-blue-btn {
    display: inline-block !important;
    width: 100% !important;
    box-sizing: border-box !important;
    margin-bottom: 15px !important;
}

/* In single mode, hide the bulk row content but keep the toggle */
body:not(.mibs-bulk-mode) .mibs-bulk-row {
    display: none !important;
}

/* Fix Add to Cart button radius to 12px to match Mighty Studio */
.variations_form .single_add_to_cart_button {
    border-radius: 12px !important;
}

/* ===== Notifications ===== */
.mibs-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    z-index: 99999;
    animation: mibs-slideIn 0.3s ease;
    max-width: 350px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.mibs-notification.success {
    background: #2e7d32;
    color: #fff;
}

.mibs-notification.error {
    background: #c62828;
    color: #fff;
}

.mibs-notification.info {
    background: #0093b0;
    color: #fff;
}

@keyframes mibs-slideIn {
    from { transform: translateX(400px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes mibs-slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(400px); opacity: 0; }
}

.mibs-notification.removing {
    animation: mibs-slideOut 0.3s ease forwards;
}

/* Highlight active discount tier in WoodMart dynamic discounts table */
body.mibs-bulk-mode .wd-dynamic-discounts tbody tr.wd-active-tier {
    background: rgba(0, 147, 176, 0.12) !important;
    box-shadow: inset 3px 0 0 var(--wd-primary-color, #0093b0);
}
body.mibs-bulk-mode .wd-dynamic-discounts tbody tr.wd-active-tier td {
    color: #fff !important;
    font-weight: 600;
}

/* Responsive ===== */
@media (max-width: 768px) {
    .mibs-color-swatches {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .mibs-color-swatch-img,
    .mibs-color-swatch-img-placeholder {
        width: 40px;
        height: 40px;
    }
    
    .mibs-bulk-container {
        padding: 0 8px;
    }
    
    .mibs-matrix-wrapper {
        font-size: 12px;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Hide the Row Total column and Total per Size footer on mobile */
    .mibs-matrix-grid .mibs-grid-head > div:last-child,
    .mibs-matrix-grid .mibs-grid-row > div:last-child,
    .mibs-matrix-grid .mibs-grid-foot > div:last-child {
        display: none !important;
    }
    
    .mibs-matrix-grid .mibs-grid-foot {
        display: none !important;
    }
    
    /* Adjust grid to use the freed space */
    .mibs-matrix-grid .mibs-grid-head,
    .mibs-matrix-grid .mibs-grid-row,
    .mibs-matrix-grid .mibs-grid-foot {
        grid-template-columns: minmax(80px, 120px) repeat(var(--mibs-size-count, 6), minmax(0, 1fr));
    }
    
    .mibs-matrix-qty-input {
        width: 40px;
        padding: 4px 2px;
        font-size: 13px;
    }
    
    .mibs-grand-total-bar {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
}

/* ===== Loading Spinner ===== */
.mibs-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: mibs-spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

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