/* Cart Modal - Mobile Optimized */

.cart-items-display,
.cart-items-display *,
.cart-table,
.cart-summary,
.cart-albums-list,
.cart-album-row {
    box-sizing: border-box;
}

.cart-items-display,
.cart-albums-list,
.cart-summary {
    width: 100%;
    max-width: 100%;
}

.cart-items-display {
    overflow-x: auto;
}

.cart-albums-list,
.cart-album-row,
.cart-summary {
    overflow-x: hidden;
}

.cart-table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}

.cart-table th,
.cart-table td,
.cart-album-row,
.cart-album-row .album-details {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.cart-album-row {
    max-width: 100%;
    min-width: 0;
}

.cart-album-row .album-details {
    min-width: 0;
}

@media (min-width: 769px) {
    .um-profile .um-profile-body,
    .um-profile .um-profile-content-container {
        max-width: calc(100vw - 54px) !important;
        box-sizing: border-box;
        overflow-x: hidden;
    }
}

.smdb-cart-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: flex-end;
    background: transparent;
    overflow-x: hidden;
}

.smdb-cart-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: -1;
}

/* Modal Container - Bottom Sheet on Mobile */
.smdb-cart-modal-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    box-sizing: border-box;
    margin: auto;
    background: #fff;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

.smdb-cart-modal-container *,
.smdb-cart-modal-container *::before,
.smdb-cart-modal-container *::after {
    box-sizing: border-box;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Modal Header */
.smdb-cart-modal-header {
    padding: 16px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.smdb-cart-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.smdb-cart-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 4px 8px;
    transition: color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.smdb-cart-modal-close:hover {
    color: #333;
}

.smdb-cart-modal-close:active {
    transform: scale(0.95);
}

/* Modal Body */
.smdb-cart-modal-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
    -webkit-overflow-scrolling: touch;
}

.smdb-cart-items-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 100%;
    min-width: 0;
}

/* Cart Item */
.smdb-cart-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: #f9f9f9;
    border-radius: 12px;
    border: 1px solid #eee;
    gap: 12px;
    transition: all 0.2s;
    max-width: 100%;
    min-width: 0;
}

.smdb-cart-item-avatar-wrap {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    overflow: visible;
}

.smdb-cart-item-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #e9e9e9;
    background: #f5f5f5;
}

.smdb-cart-item-cover {
    border-radius: 10px;
}

.smdb-cart-item-avatar-badge {
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.smdb-cart-item-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
}

.smdb-cart-item:active {
    background: #f0f0f0;
}

.smdb-cart-item-info {
    flex: 1;
    min-width: 0;
    max-width: 100%;
}

.smdb-cart-item-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 0 4px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.smdb-cart-item-price {
    font-size: 13px;
    color: #ff1493;
    font-weight: 700;
}

.smdb-cart-item-meta,
.smdb-cart-item-date {
    margin: 0;
    font-size: 11px;
    color: #777;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.smdb-cart-item-type {
    margin: 0 0 2px 0;
    font-size: 11px;
    color: #5f6c7b;
    font-weight: 600;
    line-height: 1.25;
}

.smdb-cart-item-date {
    margin-top: 2px;
}

.smdb-cart-item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.smdb-cart-item-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: #ff1493;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.smdb-cart-item-btn:active {
    transform: scale(0.95);
}

.smdb-cart-item-remove {
    background: #ccc;
}

.smdb-cart-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 16px;
    color: #999;
}

.smdb-cart-loading-shell {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 8px 2px;
}

.smdb-cart-loading-head {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #666;
    font-size: 13px;
}

.smdb-cart-skeleton-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.smdb-cart-skeleton-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    padding: 12px;
    border: 1px solid #eee;
    border-radius: 12px;
    background: #fafafa;
    align-items: center;
}

.smdb-skeleton {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #eceff1;
}

.smdb-skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.75), transparent);
    animation: smdbShimmer 1s linear infinite;
}

.smdb-skel-line {
    display: block;
    height: 12px;
}

.smdb-skel-title {
    width: 70%;
}

.smdb-skel-price {
    width: 38%;
}

.smdb-skel-btn {
    width: 34px;
    height: 34px;
    grid-column: 2;
    grid-row: 1 / span 2;
    border-radius: 10px;
}

@keyframes smdbShimmer {
    100% { transform: translateX(100%); }
}

.smdb-cart-load-error {
    text-align: center;
    padding: 24px 12px;
    color: #666;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.smdb-cart-load-error-icon {
    font-size: 24px;
    color: #e86a6a;
}

.smdb-cart-retry-btn {
    min-width: 140px;
}

.smdb-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #eee;
    border-top-color: #ff1493;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .smdb-spinner,
    .smdb-skeleton::after {
        animation: none;
    }
}

.smdb-cart-empty {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.smdb-cart-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Modal Footer */
.smdb-cart-modal-footer {
    padding: 12px;
    border-top: 1px solid #eee;
    background: #fafafa;
    flex-shrink: 0;
}

.smdb-cart-summary {
    margin-bottom: 12px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border: 1px solid #eee;
}

.smdb-cart-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.smdb-cart-label {
    font-size: 14px;
    color: #666;
}

.smdb-cart-total {
    font-size: 18px;
    font-weight: 700;
    color: #ff1493;
}

.smdb-cart-count-row {
    text-align: center;
    font-size: 12px;
    color: #999;
}

.smdb-cart-actions {
    display: flex;
    gap: 8px;
    max-width: 100%;
    min-width: 0;
}

.smdb-btn {
    flex: 1;
    min-height: 44px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.smdb-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.smdb-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.smdb-btn-primary {
    background: #ff1493;
    color: white;
}

.smdb-btn-secondary {
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ddd;
}

/* Purchase Modal */
.smdb-purchase-modal .smdb-cart-modal-container {
    max-height: 60vh;
}

.smdb-purchase-summary {
    padding: 20px;
    background: #f9f9f9;
    border-radius: 12px;
    border: 1px solid #eee;
}

.smdb-purchase-hero {
    display: flex;
    gap: 12px;
    margin-bottom: 14px;
}

.smdb-purchase-cover-wrap {
    position: relative;
    width: 74px;
    min-width: 74px;
    height: 74px;
}

.smdb-purchase-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid #e7e7e7;
    background: #fff;
}

.smdb-purchase-cover-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8f8f8f;
    font-size: 20px;
}

.smdb-purchase-advisor-avatar {
    position: absolute;
    right: -6px;
    bottom: -6px;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.smdb-purchase-meta {
    min-width: 0;
}

.smdb-purchase-item {
    margin-bottom: 16px;
}

.smdb-purchase-item:last-child {
    margin-bottom: 0;
}

.smdb-purchase-item-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.smdb-purchase-item-type,
.smdb-purchase-item-advisor,
.smdb-purchase-item-date {
    font-size: 12px;
    color: #666;
    line-height: 1.35;
}

.smdb-purchase-item-price {
    font-size: 16px;
    color: #ff1493;
    font-weight: 700;
}

.smdb-purchase-total {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 2px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.smdb-purchase-total-label {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.smdb-purchase-total-value {
    font-size: 20px;
    font-weight: 700;
    color: #ff1493;
}

.smdb-points-note {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #f7f3ff;
    border: 1px solid #e7dcff;
    color: #4f3a7a;
    font-size: 12px;
    line-height: 1.35;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.smdb-points-note i {
    margin-top: 1px;
    color: #7a4fff;
}

/* Multi-item purchase list */
.smdb-purchase-items-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
    max-height: 240px;
    overflow-y: auto;
}

.smdb-purchase-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #ebebeb;
    border-radius: 10px;
}

.smdb-purchase-list-cover-wrap {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
}

.smdb-purchase-list-cover {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e7e7e7;
    background: #f5f5f5;
    display: block;
}

.smdb-purchase-list-meta {
    flex: 1;
    min-width: 0;
}

.smdb-purchase-list-meta .smdb-purchase-item-name {
    font-size: 13px;
    font-weight: 600;
    color: #222;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.smdb-purchase-list-meta .smdb-purchase-item-type {
    font-size: 11px;
    color: #888;
}

.smdb-purchase-list-price {
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 700;
    color: #ff1493;
}

/* Success Modal */
.smdb-success-modal .smdb-cart-modal-container {
    max-height: 50vh;
    border-radius: 16px;
}

.smdb-success-icon {
    text-align: center;
    font-size: 64px;
    color: #4caf50;
    margin-bottom: 16px;
    animation: popIn 0.4s ease-out;
}

@keyframes popIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.smdb-success-modal .smdb-cart-modal-title {
    color: #4caf50;
    justify-content: center;
}

.smdb-success-modal .smdb-cart-modal-body {
    text-align: center;
    padding: 30px 20px;
}

.smdb-success-modal .smdb-cart-modal-body p {
    margin: 12px 0;
    color: #666;
    font-size: 14px;
}

/* Tablet Optimization */
@media (min-width: 480px) {
    .smdb-cart-modal-container {
        border-radius: 16px;
        max-width: 500px;
        align-self: center;
    }
    
    .smdb-cart-modal-overlay {
        align-items: center;
    }
    
    .smdb-cart-modal-header {
        padding: 20px;
    }
    
    .smdb-cart-modal-body {
        padding: 16px;
    }
    
    .smdb-cart-modal-footer {
        padding: 16px;
    }
    
    .smdb-cart-item {
        padding: 16px;
    }
}

/* Desktop Optimization */
@media (min-width: 768px) {
    .smdb-cart-modal-container {
        width: min(600px, calc(100vw - 48px));
        max-width: 600px;
        max-height: 80vh;
    }
    
    .smdb-cart-item-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .smdb-btn {
        min-height: 48px;
        font-size: 15px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .smdb-cart-modal-container,
    .smdb-cart-item,
    .smdb-cart-item-btn,
    .smdb-btn,
    .smdb-success-icon {
        animation: none !important;
        transition: none !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: more) {
    .smdb-cart-modal-container {
        border: 2px solid #000;
    }
    
    .smdb-cart-item {
        border: 2px solid #000;
    }
    
    .smdb-btn {
        border-width: 2px;
    }
}
