/* District Doctor — Diagnostic Laboratory Cart Styles */
/* Framework-Agnostic, Pure Modern CSS (Zero Bootstrap Dependency) */

:root {
    --dd-cart-primary: #0984e3;
    --dd-cart-teal: #00b894;
    --dd-cart-gold: #ffd32a;
    --dd-cart-gold-hover: #ff9f1a;
    --dd-cart-dark: #1e293b;
    --dd-cart-danger: #ef4444;
}

/* ==========================================================================
   1. Floating Cart Bar Container
   ========================================================================== */
.dd-lab-cart-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 860px;
    background: linear-gradient(135deg, #0984e3 0%, #0a899a 50%, #00b894 100%);
    color: #ffffff;
    border-radius: 20px;
    padding: 10px 16px;
    box-shadow: 0 12px 36px rgba(9, 132, 227, 0.38), 0 4px 14px rgba(0, 0, 0, 0.12);
    z-index: 1040;
    display: none;
    align-items: center;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.28);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: ddCartSlideUp 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

/* Patient Portal Specific — Exact 450px Alignment & Float Above Bottom Nav */
.dd-lab-cart-bar.dd-patient-mode {
    max-width: 426px; /* Exactly fits inside the 450px patient container with 12px margin on left & right */
    width: calc(100% - 24px);
    bottom: calc(86px + env(safe-area-inset-bottom, 0px)); /* Sits with ample padding above the fixed bottom nav (60px-70px) */
    z-index: 1020;
    padding: 10px 14px;
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(9, 132, 227, 0.45), 0 3px 12px rgba(0, 0, 0, 0.18);
}

/* ==========================================================================
   2. Inner Flex Structure (Pure CSS, No Bootstrap)
   ========================================================================== */
.dd-cart-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
    box-sizing: border-box;
}

.dd-cart-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

/* Flask / Bag Icon Bubble */
.dd-cart-icon-bubble {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-size: 16px;
    flex-shrink: 0;
    color: #ffffff;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.35);
}

.dd-cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--dd-cart-danger);
    color: #ffffff;
    font-size: 10px;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-sizing: border-box;
    border: 2px solid #ffffff;
    line-height: 1;
    box-shadow: 0 2px 5px rgba(0,0,0,0.25);
}

/* Information Text */
.dd-cart-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    line-height: 1.25;
}

.dd-cart-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dd-cart-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.2px;
}

.dd-cart-lab-pill {
    font-size: 10px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.24);
    color: #ffffff;
    padding: 2px 7px;
    border-radius: 8px;
    letter-spacing: 0.1px;
    display: inline-block;
    flex-shrink: 0;
}

.dd-cart-total-badge {
    font-size: 11px;
    font-weight: 800;
    background: #ffd32a;
    color: #0f172a;
    padding: 2px 7px;
    border-radius: 8px;
    letter-spacing: -0.1px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.22);
    flex-shrink: 0;
}

.dd-cart-sub-row {
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.92);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 4px;
}

.dd-cart-pay-val {
    font-weight: 800;
    color: var(--dd-cart-gold);
    font-size: 12.5px;
}

.dd-cart-breakdown-sub {
    font-size: 10.5px;
    opacity: 0.85;
}

.dd-cart-bal-sub {
    font-size: 10.5px;
    opacity: 0.85;
}

/* Action Buttons Group */
.dd-cart-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* View Cart Button */
.dd-btn-cart-view {
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #ffffff;
    font-size: 11.5px;
    font-weight: 600;
    padding: 7px 11px;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-sizing: border-box;
    outline: none;
}

.dd-btn-cart-view:hover,
.dd-btn-cart-view:active {
    background: rgba(255, 255, 255, 0.3);
    color: #ffffff;
    transform: translateY(-1px);
}

/* Checkout Button */
.dd-btn-cart-checkout {
    background: linear-gradient(135deg, #ffd32a 0%, #ff9f1a 100%);
    border: none;
    color: #1e272e;
    font-size: 12px;
    font-weight: 800;
    padding: 7px 13px;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(255, 159, 26, 0.36);
    transition: all 0.2s ease;
    white-space: nowrap;
    box-sizing: border-box;
    outline: none;
}

.dd-btn-cart-checkout:hover,
.dd-btn-cart-checkout:active {
    background: linear-gradient(135deg, #ffe066 0%, #ffa834 100%);
    color: #1e272e;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(255, 159, 26, 0.48);
}

/* ==========================================================================
   3. "Add to Cart" Button on Test Cards (Preserved & Enhanced)
   ========================================================================== */
.btn-add-cart {
    background: #ffffff;
    color: var(--lab-primary, #0984e3);
    border: 1.5px solid var(--lab-primary, #0984e3);
    font-weight: 700;
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 12px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
    cursor: pointer;
    text-decoration: none;
}

.btn-add-cart:hover {
    background: var(--lab-primary, #0984e3);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(9, 132, 227, 0.25);
}

.btn-add-cart.in-cart {
    background: #00b894 !important;
    border-color: #00b894 !important;
    color: #ffffff !important;
}

.btn-add-cart.in-cart:hover {
    background: #e74c3c !important;
    border-color: #e74c3c !important;
    color: #ffffff !important;
}

/* Dark mode adjustments for test card button */
.dark-mode .btn-add-cart {
    background: #1e293b;
    color: #38bdf8;
    border-color: #38bdf8;
}

.dark-mode .btn-add-cart:hover {
    background: #0284c7;
    color: #ffffff;
}

/* ==========================================================================
   4. Standalone View Cart Modal (Zero Bootstrap Dependency)
   ========================================================================== */
.dd-cart-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity 0.22s ease;
}

.dd-cart-modal-backdrop.active {
    display: flex;
    opacity: 1;
}

.dd-cart-modal-dialog {
    background: #ffffff;
    border-radius: 22px;
    width: 100%;
    max-width: 440px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    animation: ddModalPop 0.24s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
    border: 1px solid rgba(226, 232, 240, 0.9);
}

@keyframes ddModalPop {
    from {
        transform: scale(0.92) translateY(20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.dd-modal-header {
    background: linear-gradient(135deg, #0984e3 0%, #00b894 100%);
    color: #ffffff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.dd-modal-title {
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.dd-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: background 0.15s ease;
}

.dd-modal-close:hover {
    background: rgba(255, 255, 255, 0.35);
}

.dd-modal-body {
    padding: 14px 16px;
    overflow-y: auto;
    flex: 1;
    box-sizing: border-box;
}

.dd-modal-lab-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    margin-bottom: 12px;
    overflow: hidden;
}

.dd-modal-lab-head {
    background: #eef2f6;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 700;
    color: #334155;
    border-bottom: 1px solid #e2e8f0;
}

.dd-modal-lab-adv {
    background: #e0f2fe;
    color: #0369a1;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
}

.dd-modal-test-row {
    padding: 9px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f1f5f9;
}

.dd-modal-test-row:last-child {
    border-bottom: none;
}

.dd-modal-test-title {
    font-size: 12.5px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 2px;
}

.dd-modal-test-meta {
    font-size: 11px;
    color: #64748b;
}

.dd-modal-test-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dd-modal-test-price {
    font-weight: 700;
    color: #0984e3;
    font-size: 13px;
}

.dd-modal-del-btn {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 4px;
    font-size: 13px;
    border-radius: 6px;
    transition: background 0.15s ease;
}

.dd-modal-del-btn:hover {
    background: #fee2e2;
}

/* Bill Summary Box */
.dd-modal-bill-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px 14px;
    margin-top: 10px;
}

.dd-bill-line {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 6px;
}

.dd-bill-line strong {
    color: #1e293b;
}

.dd-bill-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 8px 0;
}

.dd-bill-payable-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dd-bill-payable-label {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
}

.dd-bill-payable-sub {
    font-size: 10.5px;
    color: #64748b;
}

.dd-bill-payable-amount {
    font-size: 16px;
    font-weight: 800;
    color: #00b894;
}

/* Modal Footer Actions */
.dd-modal-footer {
    padding: 10px 16px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}

.dd-modal-clear-btn {
    background: transparent;
    border: 1px solid #ef4444;
    color: #ef4444;
    font-size: 11.5px;
    font-weight: 600;
    padding: 7px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.dd-modal-clear-btn:hover {
    background: #ef4444;
    color: #ffffff;
}

.dd-modal-checkout-btn {
    background: linear-gradient(135deg, #0984e3 0%, #00b894 100%);
    border: none;
    color: #ffffff;
    font-size: 12.5px;
    font-weight: 700;
    padding: 9px 18px;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(9, 132, 227, 0.3);
    transition: all 0.2s ease;
}

.dd-modal-checkout-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(9, 132, 227, 0.45);
}

/* Dark Mode Support for Modal */
.dark-mode .dd-cart-modal-dialog {
    background: #1e293b;
    border-color: #334155;
    color: #f8fafc;
}

.dark-mode .dd-modal-lab-card,
.dark-mode .dd-modal-bill-box,
.dark-mode .dd-modal-footer {
    background: #0f172a;
    border-color: #334155;
}

.dark-mode .dd-modal-lab-head {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}

.dark-mode .dd-modal-test-title,
.dark-mode .dd-bill-line strong,
.dark-mode .dd-bill-payable-label {
    color: #f8fafc;
}

.dark-mode .dd-modal-test-meta,
.dark-mode .dd-bill-line,
.dark-mode .dd-bill-payable-sub {
    color: #94a3b8;
}

.dark-mode .dd-modal-test-row {
    border-color: #334155;
}

.dark-mode .dd-bill-divider {
    background: #334155;
}

/* ==========================================================================
   5. Compact Mobile Responsiveness (< 390px)
   ========================================================================== */
@media (max-width: 390px) {
    .dd-lab-cart-bar.dd-patient-mode {
        padding: 8px 10px;
    }
    .dd-cart-icon-bubble {
        width: 34px;
        height: 34px;
        font-size: 14px;
    }
    .dd-cart-title {
        font-size: 12px;
    }
    .dd-cart-lab-pill {
        font-size: 9px;
        padding: 1px 5px;
    }
    .dd-cart-sub-row {
        font-size: 10.5px;
    }
    .dd-btn-cart-view {
        padding: 6px 8px;
        font-size: 11px;
    }
    .dd-btn-cart-view span.dd-btn-label {
        display: none; /* Icon only on extra small */
    }
    .dd-btn-cart-checkout {
        padding: 6px 10px;
        font-size: 11.5px;
    }
    .dd-cart-bal-sub {
        display: none; /* Hide Bal text on ultra-narrow screens to prevent wrapping */
    }
}
