/* ================================
   CART PAGE - STABLE LAYOUT
================================ */


.cart-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    color: #0E2032;
}

.cart-page h1 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 28px;
    color: #0E2032;
}

/* ================================
   HEADER
================================ */

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.continue-shopping-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #dce1e7;
    padding: 10px 18px;
    background: #fff;
    color: #0E2032;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.continue-shopping-btn:hover {
    background: #f6f7f9;
    border-color: #56C9F4;
}

/* ================================
   LAYOUT
================================ */

.cart-content {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    align-items: start;
}

.cart-left-side {
    min-width: 0;
}

.cart-items {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ================================
   CART ITEM CARD
================================ */

.cart-item-card {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 20px;
    padding: 18px;
    background: white;
    border: 1px solid #e8eaed;
    box-shadow: 0 1px 2px rgba(14, 32, 50, 0.04);
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.cart-item-image img,
.cart-item-image-placeholder {
    border: 1px solid #eef0f3;
}

.cart-item-image {
    width: 100px;
    height: 100px;
    flex-shrink: 0;
}

.cart-item-image img,
.cart-item-image-placeholder {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ================================
   DETAILS
================================ */

.cart-item-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.cart-item-name {
    font-size: 1rem;
    font-weight: 700;
    color: #0E2032;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item-name a {
    color: inherit;
    text-decoration: none;
}

.cart-item-variant {
    font-size: 0.9rem;
    color: #666;
}

.cart-item-stock {
    font-size: 0.85rem;
}

.cart-item-stock.low {
    color: #f59e0b;
}

.cart-item-stock.out {
    color: #dc2626;
    font-weight: 600;
}

.cart-item-stock.in {
    color: #15803d;
}

.cart-item-brand {
    font-size: 0.85rem;
    color: var(--njorka-light-blue);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.cart-item-sku {
    font-size: 0.8rem;
    color: #9ca3af;
}

.cart-item-unit-price {
    font-size: 0.8rem;
    color: #9ca3af;
    white-space: nowrap;
}

/* ================================
   ACTIONS (GRID – NO FLEX CHAOS)
================================ */

.cart-item-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
    margin-top: auto;
    min-width: 0;
}

/* Quantity */

.cart-item-quantity {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.quantity-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid #dce1e7;
    background: white;
}

.quantity-btn {
    width: 40px;
    border: none;
    background: #f6f7f9;
    color: #0E2032;
    font-weight: 700;
    cursor: pointer;
    font-size: 1rem;
}

.quantity-btn:hover:not(:disabled) {
    background: #e8eaed;
}

.quantity-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.quantity-input {
    width: 50px;
    border: none;
    text-align: center;
    font-size: 0.95rem;
    outline: none;
}

/* Right Side */

.cart-item-actions-right {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.cart-item-total {
    font-weight: 800;
    color: #0E2032;
    white-space: nowrap;
}

.cart-item-remove {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1.1rem;
}

/* ================================
   TOTALS SIDEBAR
================================ */

.cart-totals {
    position: sticky;
    top: 120px;
    padding: 24px;
    background: #fff;
    border: 1px solid #e8eaed;
}

.cart-totals::before {
    content: "";
    display: block;
    height: 3px;
    margin: -24px -24px 20px;
    background: linear-gradient(90deg, #56C9F4, #1AABCF);
}

.totals-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #e5e7eb;
}

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

.totals-row.tax {
    border-bottom: none;
    padding-bottom: 0px;
}

.totals-row.total {
    font-weight: 800;
    font-size: 1.2rem;
    color: #0E2032;
    border-top: 2px solid #e8eaed;
    margin-top: 10px;
    padding-top: 14px;
}

.checkout-btn {
    width: 100%;
    padding: 14px;
    margin-top: 20px;
    background: #56C9F4;
    color: white;
    border: 2px solid #56C9F4;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    text-decoration: none;
    display: block;
    text-align: center;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.checkout-btn:hover {
    background: #fff;
    color: #56C9F4;
    box-shadow: 0 6px 16px rgba(86, 201, 244, 0.25);
}

.cart-discount-applier {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid #e5e7eb;
}

.cart-discount-applier .discount-helper {
    margin: 0 0 12px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #0f172a;
}

.cart-discount-applier form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
}

.cart-discount-applier .mall-form-control {
    min-width: 0;
    position: relative;
    padding-bottom: 22px;
}

.cart-discount-applier label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.cart-discount-applier input[type="text"] {
    width: 100%;
    min-width: 0;
    padding: 11px 12px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #0f172a;
    font-size: 0.9rem;
    text-transform: uppercase;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.cart-discount-applier input[type="text"]::placeholder {
    color: #94a3b8;
    text-transform: none;
}

.cart-discount-applier input[type="text"]:focus {
    outline: none;
    border-color: var(--njorka-light-blue);
    box-shadow: 0 0 0 3px rgba(86, 201, 244, 0.18);
}

.cart-discount-applier .mall-btn {
    padding: 11px 16px;
    border: 1px solid var(--njorka-light-blue);
    background: var(--njorka-light-blue);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    align-self: start;
}

.cart-discount-applier .mall-btn:hover,
.cart-discount-applier .mall-btn:focus {
    background: #fff;
    color: var(--njorka-light-blue);
    outline: none;
}

.cart-discount-applier [data-validate-for="code"] {
    position: absolute;
    left: 0;
    top: calc(100% - 18px);
    font-size: 0.85rem;
    color: #dc2626;
}

.applied-discounts {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.applied-discount-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: #ffffff;
    border: 1px solid #dbe4ee;
}

.applied-discount-copy {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.applied-discount-copy strong {
    font-size: 0.9rem;
    color: #0f172a;
}

.applied-discount-copy span {
    font-size: 0.8rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.applied-discount-actions {
    display: grid;
    justify-items: end;
    gap: 6px;
    flex: 0 0 auto;
}

.applied-discount-savings {
    font-size: 0.9rem;
    font-weight: 700;
    color: #15803d;
    white-space: nowrap;
}

.applied-discount-remove {
    padding: 0;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 0.8rem;
    text-decoration: underline;
    cursor: pointer;
}

.applied-discount-remove:hover {
    color: #0f172a;
}

.secure-checkout {
    margin-top: 14px;
    font-size: 0.85rem;
    text-align: center;
    color: #666;
}

/* ================================
   EMPTY STATE
================================ */

.cart-empty {
    text-align: center;
    padding: 80px 20px;
}

/* ================================
   RESPONSIVE
================================ */

@media (max-width: 1024px) {
    .cart-content {
        grid-template-columns: 1fr;
    }

    .cart-totals {
        position: static;
    }
}

@media (max-width: 768px) {

    .cart-page {
        padding: 20px 12px;
    }

    .cart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .cart-item-card {
        grid-template-columns: 80px 1fr;
        gap: 12px;
        padding: 14px;
    }

    .cart-item-image {
        width: 80px;
        height: 80px;
    }

    .cart-item-actions {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .cart-item-actions-right {
        justify-content: space-between;
        width: 100%;
    }

    .quantity-btn {
        width: 32px;
    }

    .quantity-input {
        width: 40px;
    }

    .cart-totals {
        margin-top: 20px;
        padding: 18px;
    }

    .cart-discount-applier form {
        grid-template-columns: 1fr;
    }

    .cart-discount-applier .mall-btn {
        width: 100%;
    }

    .applied-discount-item {
        flex-direction: column;
    }

    .applied-discount-actions {
        width: 100%;
        grid-template-columns: 1fr auto;
        align-items: center;
        justify-items: stretch;
    }

    .applied-discount-remove {
        justify-self: end;
    }
}

@media (max-width: 480px) {

    .cart-item-card {
        grid-template-columns: 70px 1fr;
    }

    .cart-item-image {
        width: 70px;
        height: 70px;
    }

    .cart-item-name {
        font-size: 0.95rem;
    }

    .cart-item-total {
        font-size: 0.95rem;
    }
}

/* ================================
   CUSTOM CONFIRM DIALOG
================================ */

.custom-dialog {
    border: 1px solid #e8eaed;
    padding: 0;
    max-width: 400px;
    box-shadow: 0 16px 48px rgba(14, 32, 50, 0.22);
    animation: dialogSlideIn 0.3s ease;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}

.custom-dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.custom-dialog .dialog-content {
    padding: 32px 24px;
}

.custom-dialog #confirm-title {
    margin: 0 0 12px 0;
    font-size: 1.25rem;
    font-weight: 800;
    color: #0E2032;
}

.custom-dialog #confirm-message {
    margin: 0 0 24px 0;
    font-size: 1rem;
    color: #555;
    line-height: 1.5;
}

.custom-dialog .dialog-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.custom-dialog .dialog-buttons button {
    padding: 12px 24px;
    border: none;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.custom-dialog #confirm-cancel {
    background: #f3f4f6;
    color: #333;
}

.custom-dialog #confirm-cancel:hover {
    background: #e5e7eb;
}

.custom-dialog #confirm-yes {
    background: #dc2626;
    color: white;
}

.custom-dialog #confirm-yes:hover {
    background: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

@keyframes dialogSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@media (max-width: 480px) {
    .custom-dialog {
        margin: 0;
        left: 50%;
        right: auto;
        max-width: calc(100% - 40px);
    }

    .custom-dialog .dialog-buttons {
        flex-direction: column;
    }

    .custom-dialog .dialog-buttons button {
        width: 100%;
    }
}

/* ================================
   SUMMARY EXTRAS
================================ */

.cart-summary-count {
    font-size: 0.85rem;
    font-weight: 400;
    color: #9ca3af;
}

.totals-row.cart-shipping-note span:last-child {
    color: #9ca3af;
    font-style: italic;
    font-size: 0.9rem;
}

.cart-trust {
    list-style: none;
    margin: 18px 0 0;
    padding: 16px 0 0;
    border-top: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cart-trust li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: #64748b;
}

.cart-trust li i {
    color: var(--njorka-light-blue);
    font-size: 1rem;
    flex-shrink: 0;
}
