/* ==========================================
   Product Detail Modal & Shopping Cart
   Mobile-first responsive
   ========================================== */

/* ---- Product Detail Modal ---- */
.pdm-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6); z-index: 1000;
    display: none; align-items: flex-end; justify-content: center;
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.pdm-overlay.show { display: flex; }

.pdm-sheet {
    background: white; width: 100%; max-width: 500px;
    max-height: 92vh; border-radius: 20px 20px 0 0;
    overflow-y: auto; position: relative;
    animation: slideUp 0.3s ease;
    -webkit-overflow-scrolling: touch;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.pdm-sheet .pdm-handle {
    width: 40px; height: 4px; background: #ddd; border-radius: 4px;
    margin: 10px auto 0; display: block;
}
.pdm-close {
    position: absolute; top: 12px; left: 12px; z-index: 5;
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(0,0,0,0.5); color: white; border: none;
    font-size: 16px; cursor: pointer; display: flex;
    align-items: center; justify-content: center;
}
/* Gallery / Image Slider */
.pdm-gallery { position: relative; width: 100%; height: 220px; overflow: hidden; background: #f5f5f5; }
.pdm-slides { width: 100%; height: 100%; position: relative; }
.pdm-slide {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover; background-position: center;
    opacity: 0; transition: opacity 0.4s ease;
}
.pdm-slide.active { opacity: 1; }
.pdm-dots {
    position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 6px; z-index: 3;
}
.pdm-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: rgba(255,255,255,0.5); cursor: pointer;
    transition: all 0.3s;
}
.pdm-dot.active { background: white; width: 20px; border-radius: 4px; }
.pdm-body { padding: 20px; }
.pdm-name { font-size: 22px; font-weight: 800; color: #222; margin-bottom: 6px; }
.pdm-desc { font-size: 14px; color: #888; line-height: 1.6; margin-bottom: 12px; }
.pdm-price-row {
    display: flex; align-items: center; gap: 6px;
    margin-bottom: 16px;
}
.pdm-price-value { font-size: 24px; font-weight: 800; color: #1565c0; }
.pdm-currency { font-size: 14px; color: #999; }

.pdm-info-badges { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.pdm-badge {
    display: inline-flex; align-items: center; gap: 5px;
    background: #f5f5f5; padding: 6px 14px; border-radius: 20px;
    font-size: 12px; color: #666;
}
.pdm-badge i { font-size: 11px; }

.pdm-ingredients { margin-bottom: 16px; }
.pdm-ingredients .pdm-ig-title { font-weight: 700; font-size: 14px; color: #444; margin-bottom: 4px; }
.pdm-ingredients .pdm-ing-list { font-size: 13px; color: #888; line-height: 1.5; }

/* Option Groups */
.pdm-option-group { margin-bottom: 16px; border: 1px solid #f0f0f0; border-radius: 12px; overflow: hidden; }
.pdm-og-title {
    font-weight: 700; font-size: 14px; color: #333;
    padding: 10px 14px; background: #fafafa;
    display: flex; align-items: center; gap: 8px;
}
.pdm-required { font-size: 10px; background: #ffebee; color: #c62828; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.pdm-option-item {
    display: flex; align-items: center; padding: 10px 14px;
    border-top: 1px solid #f5f5f5; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.pdm-option-item:active { background: #fafafa; }
.pdm-option-item input { margin-left: 10px; accent-color: #1565c0; width: 18px; height: 18px; flex-shrink: 0; }
.pdm-opt-name { flex: 1; font-size: 14px; color: #444; }
.pdm-opt-price { font-size: 13px; color: #1565c0; font-weight: 600; white-space: nowrap; }

/* Add to cart bar */
.pdm-footer {
    padding: 16px 20px; border-top: 1px solid #f0f0f0;
    display: flex; align-items: center; gap: 12px;
    background: white;
    position: sticky; bottom: 0;
}
.pdm-qty {
    display: flex; align-items: center; gap: 0;
    background: #f5f5f5; border-radius: 12px; overflow: hidden;
}
.pdm-qty button {
    width: 40px; height: 40px; border: none; background: transparent;
    font-size: 16px; cursor: pointer; color: #333;
    display: flex; align-items: center; justify-content: center;
}
.pdm-qty button:active { background: #e0e0e0; }
.pdm-qty-value { width: 32px; text-align: center; font-size: 16px; font-weight: 700; }

.pdm-add-btn {
    flex: 1; padding: 12px 16px; border: none;
    background: linear-gradient(135deg, #1565c0, #0d47a1);
    color: white; border-radius: 12px;
    font-family: 'Tajawal', sans-serif;
    font-size: 15px; font-weight: 700;
    cursor: pointer; display: flex;
    align-items: center; justify-content: space-between;
    transition: all 0.2s;
}
.pdm-add-btn:active { transform: scale(0.97); }
.pdm-total-price { font-size: 14px; font-weight: 800; }

/* ---- Floating Cart Button ---- */
.cart-fab {
    position: fixed; bottom: 20px; left: 20px; z-index: 900;
    width: 60px; height: 60px; border-radius: 50%;
    background: linear-gradient(135deg, #1565c0, #0d47a1);
    color: white; border: none; font-size: 24px;
    box-shadow: 0 6px 25px rgba(21,101,192,0.5);
    cursor: pointer; display: none;
    align-items: center; justify-content: center;
    animation: fabPulse 2s infinite;
}
@keyframes fabPulse {
    0%, 100% { box-shadow: 0 6px 25px rgba(21,101,192,0.5); }
    50% { box-shadow: 0 6px 35px rgba(21,101,192,0.7); }
}
.cart-fab:active { transform: scale(0.9); }
.cart-fab .cart-badge {
    position: absolute; top: -4px; right: -4px;
    background: #e53935; color: white; width: 24px; height: 24px;
    border-radius: 50%; font-size: 12px; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
}

/* ---- Cart Panel ---- */
.cart-panel-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 1001;
    display: none; align-items: flex-end; justify-content: center;
    backdrop-filter: blur(3px);
}
.cart-panel-overlay.show { display: flex; }

.cart-panel {
    background: white; width: 100%; max-width: 500px;
    max-height: 80vh; border-radius: 20px 20px 0 0;
    display: flex; flex-direction: column;
    animation: slideUp 0.3s ease;
}
.cart-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid #f0f0f0;
}
.cart-header h3 { font-size: 18px; font-weight: 800; margin: 0; color: #222; }
.cart-header button { background: none; border: none; font-size: 22px; color: #999; cursor: pointer; padding: 4px; }

.cart-body { flex: 1; overflow-y: auto; padding: 12px 20px; -webkit-overflow-scrolling: touch; }

.cart-empty {
    text-align: center; padding: 40px 20px; color: #ccc;
}
.cart-empty i { font-size: 48px; display: block; margin-bottom: 12px; }

.cart-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 0; border-bottom: 1px solid #f5f5f5;
}
.cart-item:last-child { border-bottom: none; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: 15px; font-weight: 700; color: #333; }
.cart-item-opts { font-size: 11px; color: #aaa; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-item-price { font-size: 14px; font-weight: 700; color: #1565c0; margin-top: 4px; }
.cart-item-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; margin-right: 12px; }

.cart-qty-controls {
    display: flex; align-items: center; gap: 0;
    background: #f5f5f5; border-radius: 10px; overflow: hidden;
}
.cart-qty-controls button {
    width: 32px; height: 32px; border: none; background: transparent;
    font-size: 12px; cursor: pointer; color: #333;
    display: flex; align-items: center; justify-content: center;
}
.cart-qty-controls button:active { background: #e0e0e0; }
.cart-qty-controls span { width: 26px; text-align: center; font-weight: 700; font-size: 14px; }

.cart-remove-btn { background: none; border: none; color: #e53935; font-size: 14px; cursor: pointer; padding: 6px; }

.cart-footer {
    padding: 16px 20px; border-top: 1px solid #eee;
    background: #fafafa;
}
.cart-total-row {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px;
}
.cart-total-label { font-size: 16px; font-weight: 700; color: #333; }
.cart-total-price { font-size: 22px; font-weight: 800; color: #1565c0; }

.cart-clear-btn {
    width: 100%; padding: 10px; border: 1px solid #e0e0e0; background: white;
    border-radius: 10px; font-family: 'Tajawal', sans-serif;
    font-size: 13px; color: #999; cursor: pointer; text-align: center;
}

/* ---- Cart Notification Toast ---- */
.cart-notification {
    position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: #2e7d32; color: white; padding: 12px 24px; border-radius: 12px;
    font-size: 14px; font-weight: 600; z-index: 2000;
    opacity: 0; transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    white-space: nowrap; max-width: 90%; text-align: center;
}
.cart-notification.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.cart-notification i { margin-left: 6px; }

/* ---- Safe area ---- */
@supports (padding: max(0px)) {
    .pdm-footer { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
    .cart-fab { bottom: max(20px, calc(env(safe-area-inset-bottom) + 10px)); }
    .cart-footer { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
}

/* ---- Desktop ---- */
@media (min-width: 768px) {
    .pdm-overlay { align-items: center; }
    .pdm-sheet { border-radius: 20px; max-height: 85vh; }
    .pdm-gallery { height: 280px; border-radius: 20px 20px 0 0; }
    .cart-panel-overlay { align-items: center; }
    .cart-panel { border-radius: 20px; max-height: 70vh; }
    .cart-fab { bottom: 30px; left: 30px; width: 64px; height: 64px; }
}
