/* ============================================================
   FlashDeals UK — Design System Styles
   Tailwind handles most styling. This file adds:
   1. Animations
   2. Custom components
   3. Scrollbar hiding
   4. Focus states
   ============================================================ */

/* ===== ALPINE.JS x-cloak ===== */
[x-cloak] { display: none !important; }

/* ===== GLOBAL SCROLL SAFETY ===== */
html, body { overflow-x: hidden; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOutRight { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(100%); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }
@keyframes spin { to { transform: rotate(360deg); } }

.animate-fade-in { animation: fadeIn .25s ease-out; }
.animate-slide-in { animation: slideInRight .25s ease-out; }
.animate-pulse-once { animation: pulse .35s ease-in-out; }
.animate-spin { animation: spin 1s linear infinite; }

/* ===== TOAST NOTIFICATIONS ===== */
.toast-msg {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: .875rem;
    font-weight: 500;
    box-shadow: 0 10px 40px rgba(0,0,0,.15);
    pointer-events: auto;
    animation: slideInRight .25s ease-out;
    transition: all .3s ease;
}
.toast-success { background: #065f46; color: #ecfdf5; }
.toast-error   { background: #991b1b; color: #fef2f2; }
.toast-info    { background: #1e40af; color: #eff6ff; }
.toast-close {
    background: none; border: none; color: inherit; opacity: .6;
    cursor: pointer; font-size: 1rem; margin-left: auto; padding: 0 2px;
    transition: opacity .15s;
}
.toast-close:hover { opacity: 1; }

/* ===== SCROLLBAR HIDE UTILITY ===== */
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

/* ===== PRODUCT CARD ===== */
.product-card {
    transition: all .2s ease;
}
.product-card:hover {
    box-shadow: 0 10px 30px rgba(0,0,0,.1);
    transform: translateY(-2px);
}
.product-card:hover .product-card-img img {
    transform: scale(1.05);
}
.product-card-img {
    overflow: hidden;
}
.product-card-img img {
    transition: transform .35s ease;
}

/* ===== STAR RATING INPUT ===== */
.star-rating-input .star {
    cursor: pointer;
    transition: color .12s;
    font-size: 1.25rem;
    color: #d1d5db;
}
.star-rating-input .star:hover,
.star-rating-input .star.active {
    color: #f59e0b;
}
.star-rating-input .star.hover {
    color: #fbbf24;
}

/* ===== CART QUANTITY CONTROLS ===== */
.cart-qty-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 10px;
    cursor: pointer;
    transition: all .12s;
    font-size: .875rem;
    color: #475569;
}
.cart-qty-btn:hover {
    border-color: #2563eb;
    color: #2563eb;
    background: #eff6ff;
}
.cart-qty-input {
    width: 48px;
    text-align: center;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-weight: 600;
    font-size: .875rem;
    color: #0f172a;
}

/* ===== VARIANT PILLS ===== */
.variant-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 9999px;
    font-size: .875rem;
    cursor: pointer;
    background: white;
    transition: all .12s;
    color: #334155;
}
.variant-pill:hover {
    border-color: #93c5fd;
}
.variant-pill.active {
    border-color: #2563eb;
    background: #eff6ff;
    font-weight: 600;
    color: #1d4ed8;
}
.variant-pill input { display: none; }

/* ===== IMAGE GALLERY THUMBNAILS ===== */
.pd-thumb {
    width: 64px;
    height: 64px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    object-fit: cover;
    cursor: pointer;
    opacity: .5;
    transition: all .15s;
}
.pd-thumb:hover,
.pd-thumb.active {
    opacity: 1;
    border-color: #2563eb;
}

/* ===== REVIEW BREAKDOWN BARS ===== */
.review-bar {
    height: 8px;
    background: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
}
.review-bar-fill {
    height: 100%;
    background: #f59e0b;
    border-radius: 4px;
    transition: width .6s ease;
}

/* ===== PAYMENT OPTION CARDS ===== */
.payment-option {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all .12s;
    display: flex;
    align-items: center;
    gap: 12px;
}
.payment-option:hover {
    border-color: #93c5fd;
}
.payment-option.active {
    border-color: #2563eb;
    background: #eff6ff;
}
.payment-option input[type="radio"] {
    accent-color: #2563eb;
}

/* ===== SAFE BOTTOM (for mobile bottom nav) ===== */
.safe-bottom {
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ===== CUSTOM SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== X-CLOAK (Alpine.js) ===== */
[x-cloak] { display: none !important; }

/* ===== FOCUS STATES (Accessibility — keyboard navigation) ===== */
:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
    border-radius: 4px;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37,99,235,.25);
    border-color: #2563eb;
}
button:focus-visible,
a:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* ===== SKIP TO CONTENT LINK ===== */
.skip-link {
    position: absolute;
    top: -100%;
    left: 16px;
    z-index: 9999;
    background: #2563eb;
    color: white;
    padding: 12px 24px;
    border-radius: 0 0 8px 8px;
    font-weight: 600;
    font-size: .875rem;
    text-decoration: none;
    transition: top .2s;
}
.skip-link:focus {
    top: 0;
}

/* ===== SCREEN READER ONLY ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border-width: 0;
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== HIGH CONTRAST MODE ===== */
@media (forced-colors: active) {
    .variant-pill.active,
    .payment-option.active {
        border: 2px solid ButtonText;
    }
    .toast-msg {
        border: 1px solid ButtonText;
    }
}

/* ===== LINK UNDERLINE HOVER ===== */
.link-underline {
    text-decoration: none;
    transition: color .15s;
}
.link-underline:hover {
    text-decoration: underline;
}

/* ===== CATEGORY CARD HOVER ===== */
.category-card {
    position: relative;
    overflow: hidden;
    border-radius: 1rem;
}
.category-card img {
    transition: transform .7s ease-out;
}
.category-card:hover img {
    transform: scale(1.1);
}
.category-card .cat-overlay {
    opacity: .6;
    transition: opacity .3s ease;
}
.category-card:hover .cat-overlay {
    opacity: .8;
}
.category-card .cat-cta {
    opacity: 0;
    transform: translateY(8px);
    transition: all .3s ease .1s;
}
.category-card:hover .cat-cta {
    opacity: 1;
    transform: translateY(0);
}

/* ===== PRODUCT CARD IMAGE HOVER ===== */
.product-card .card-img-primary {
    transition: opacity .5s ease;
}
.product-card .card-img-secondary {
    opacity: 0;
    transition: opacity .5s ease;
    position: absolute;
    inset: 0;
}
.product-card:hover .card-img-primary {
    opacity: 0;
}
.product-card:hover .card-img-secondary {
    opacity: 1;
}

/* ===== MOBILE NAVIGATION ===== */
/* Drawer overscroll bounce prevention */
.mobile-drawer-open {
    overflow: hidden;
    position: fixed;
    inset: 0;
    width: 100%;
}

/* Floating cart FAB pulse on cart update */
@keyframes fab-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}
.fab-pulse {
    animation: fab-pulse .3s ease-in-out;
}

/* Bottom nav active state indicator */
.bottom-nav-active {
    position: relative;
}
.bottom-nav-active::after {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 2px;
    background: #2563eb;
    border-radius: 0 0 2px 2px;
}

/* ===== SKELETON LOADERS ===== */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 37%, #f1f5f9 63%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}
.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-text-sm { height: 11px; margin-bottom: 6px; }
.skeleton-text-lg { height: 20px; margin-bottom: 10px; }
.skeleton-circle { border-radius: 50%; }
.skeleton-card {
    background: white;
    border-radius: 1rem;
    border: 1px solid #f1f5f9;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

/* ===== MODAL SYSTEM ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-content {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 25px 60px rgba(0,0,0,.25);
    max-height: 90vh;
    overflow-y: auto;
    width: 100%;
    animation: modalIn .25s ease-out;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-sm { max-width: 24rem; }
.modal-md { max-width: 32rem; }
.modal-lg { max-width: 48rem; }
.modal-xl { max-width: 64rem; }

/* ===== ERROR STATES ===== */
.error-page {
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 1rem;
}
.error-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

/* ===== TOAST ACCESSIBILITY ===== */
.toast-msg[role="alert"] {
    aria-live: assertive;
}
.toast-msg[role="status"] {
    aria-live: polite;
}

/* ===== IMAGE LAZY LOADING ===== */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity .3s ease;
}
img[loading="lazy"].loaded,
img[loading="lazy"][src] {
    opacity: 1;
}

/* ===== LAYOUT SHIFT PREVENTION ===== */
.img-placeholder {
    background: #f1f5f9;
    aspect-ratio: 1;
    width: 100%;
}
.aspect-square { aspect-ratio: 1; }
.aspect-video { aspect-ratio: 16/9; }
