/* ═══ iMatrix Slide-In Cart Panel ═══ */

/* ─── Overlay ─── */
.imatrix-cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.imatrix-cart-overlay.imatrix-open {
    opacity: 1;
    visibility: visible;
}

/* ─── Slide-in Panel ─── */
.imatrix-cart-slidein {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    max-width: 100%;
    height: 100vh;
    background: #fff;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2);
    transition: right 0.3s ease;
}
.imatrix-cart-slidein.imatrix-open {
    right: 0;
}

/* Header */
.imatrix-cart-slidein-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e5e5;
    background: #1a73e8; /* iMatrix blue */
    color: #fff;
    flex-shrink: 0;
}
.imatrix-cart-slidein-header h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.imatrix-cart-slidein-header .imatrix-cart-count-badge {
    background: #fff;
    color: #1a73e8;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
}

/* Close button */
.imatrix-cart-slidein-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}
.imatrix-cart-slidein-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Content area */
.imatrix-cart-slidein-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 20px;
}

/* ─── Cart Items List ─── */
.imatrix-cart-slidein-items {
    list-style: none;
    margin: 0;
    padding: 0;
}
.imatrix-cart-slidein-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}
.imatrix-cart-slidein-item:last-child {
    border-bottom: none;
}

/* Bug 5 fix: only show image container when an image actually exists */
.imatrix-cart-slidein-item-img {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    background: #f5f5f5;
}
.imatrix-cart-slidein-item-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
/* If no inner img, kill the placeholder visual entirely */
.imatrix-cart-slidein-item-img:empty {
    display: none;
}

.imatrix-cart-slidein-item-details {
    flex: 1;
    min-width: 0;
}
.imatrix-cart-slidein-item-name {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
    color: #1a1a1a;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.imatrix-cart-slidein-item-meta {
    display: block;
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 4px;
}
.imatrix-cart-slidein-item-price {
    display: block;
    font-weight: 600;
    color: #1a73e8;
    font-size: 0.9rem;
}

/* ─── Quantity Controls ─── */
.imatrix-cart-qty-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}
/* BUG 3: Hide qty row for OSINT single-quantity items */
.imatrix-cart-osint-item .imatrix-cart-qty-row {
    display: none;
}
.imatrix-cart-qty-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
    padding: 0;
    line-height: 1;
}
.imatrix-cart-qty-btn:hover {
    background: #f0f0f0;
    border-color: #1a73e8;
}
.imatrix-cart-qty-value {
    min-width: 28px;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
}
.imatrix-cart-item-remove {
    background: none;
    border: none;
    color: #c0392b;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px;
    margin-left: auto;
    transition: color 0.2s;
}
.imatrix-cart-item-remove:hover {
    color: #e74c3c;
}

/* ─── Empty State ─── */
.imatrix-cart-slidein-empty {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}
.imatrix-cart-slidein-empty p {
    margin-bottom: 20px;
    font-size: 1rem;
}

/* ─── Footer ─── */
.imatrix-cart-slidein-footer {
    padding: 16px 20px;
    border-top: 1px solid #e5e5e5;
    background: #fafafa;
    flex-shrink: 0;
}
.imatrix-cart-slidein-subtotal {
    display: flex;
    justify-content: space-between;
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: #1a1a1a;
}
.imatrix-cart-slidein-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.imatrix-cart-slidein-actions .button {
    width: 100%;
    text-align: center;
    padding: 10px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: opacity 0.2s;
}
.imatrix-cart-slidein-actions .button:hover {
    opacity: 0.9;
}
.imatrix-cart-slidein-actions .imatrix-cart-btn-checkout {
    background: #1a73e8;
    color: #fff;
    border: none;
}
.imatrix-cart-slidein-actions .imatrix-cart-btn-continue {
    background: #fff;
    color: #1a73e8;
    border: 1px solid #1a73e8;
}

/* ─── Floating Toggle Button ─── */
.imatrix-cart-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9997;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #1a73e8;
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    transition: transform 0.2s, box-shadow 0.2s;
}
.imatrix-cart-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}
.imatrix-cart-toggle .imatrix-cart-toggle-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e74c3c;
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* ─── Legacy static sidebar (hidden when slide-in active) ─── */
#imatrix-cart-panel.widget {
    display: none !important;
}

/* ─── Mobile: full-width panel ─── */
@media (max-width: 480px) {
    .imatrix-cart-slidein {
        width: 100%;
        right: -100%;
    }
    .imatrix-cart-slidein.imatrix-open {
        right: 0;
    }
    .imatrix-cart-toggle {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }
}

/* ─── Loading spinner for AJAX operations ─── */
.imatrix-cart-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}
.imatrix-cart-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #1a73e8;
    border-top-color: transparent;
    border-radius: 50%;
    animation: imatrix-spin 0.8s linear infinite;
}
@keyframes imatrix-spin {
    to { transform: rotate(360deg); }
}

/* ─── Product page domain field styling ─── */
.imatrix-osint-domain-field-wrapper {
    margin-bottom: 1rem;
    padding: 12px 16px;
    background: #f8f9fa;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
}
.imatrix-osint-domain-field-wrapper label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #1a1a1a;
}
.imatrix-osint-domain-field-wrapper .input-text {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.imatrix-osint-domain-field-wrapper .input-text:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
    outline: none;
}
.imatrix-domain-hint {
    display: block;
    font-size: 0.8rem;
    color: #666;
    margin-top: 4px;
}
.imatrix-domain-msg {
    display: block;
    font-size: 0.85rem;
    margin-top: 4px;
    min-height: 1.2em;
}
.imatrix-domain-msg.imatrix-valid {
    color: #27ae60;
}
.imatrix-domain-msg.imatrix-invalid {
    color: #c0392b;
}

/* ─── Checkout order review remove button ─── */
.imatrix-checkout-remove-item {
    font-size: 1.1rem;
    margin-left: 6px;
    color: #c0392b;
    text-decoration: none;
    cursor: pointer;
    line-height: 1;
    vertical-align: middle;
    min-width: 20px;
    display: inline-block;
    text-align: center;
    border-radius: 3px;
    padding: 1px 4px;
}
.imatrix-checkout-remove-item:hover {
    color: #e74c3c;
    background: #fdf2f2;
}
