/**
 * Kepong Firework - Custom Styles
 * A vibrant, festive design for fireworks e-commerce
 */

/* ============ CSS Variables ============ */
:root {
    --primary-color: rgb(13, 7, 77);
    --primary-color-dark: rgb(8, 4, 55);
    --primary-color-light: rgb(30, 20, 120);
    --gold: #ffc107;
    --gold-dark: #e0a800;
    --dark: #1a1a2e;
    --light-bg: #f5f5ff;
    --gradient-festive: linear-gradient(135deg, rgb(13, 7, 77) 0%, rgb(30, 20, 120) 50%, #ffc107 100%);
    --gradient-hero: linear-gradient(135deg, rgba(13, 7, 77, 0.5) 0%, rgba(26, 26, 46, 0.2) 100%);
    --shadow-soft: 0 4px 15px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 8px 25px rgba(13, 7, 77, 0.3);
    --transition: all 0.3s ease;
}

/* ============ Typography ============ */
body {
    font-family: 'Poppins', 'Noto Sans SC', sans-serif;
    background-color: #fafafa;
}

/* ============ File Input Fix ============ */
input[type="file"].form-control {
    cursor: pointer !important;
    pointer-events: auto !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 10 !important;
}

input[type="file"].form-control::file-selector-button {
    cursor: pointer !important;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
}

/* ============ Hero Section ============ */
.hero-section {
    /* background: url('../images/firework-bg.jpg') center center / cover no-repeat; */
    background: url('../images/firework-animation.gif') center center / cover no-repeat;
    background-color: var(--dark);
    position: relative;
    min-height: 80vh;
    display: flex;
    align-items: center;
}

/* Mobile Hero - Better aspect ratio and positioning */
@media (max-width: 576px) {
    .hero-section {
        min-height: 40vh;
        background-position: center center;
        background-size: cover;
        /* 
         * OPTION: Use a different image for mobile
         * Uncomment and add your mobile banner image:
         * background-image: url('../images/firework-bg-mobile.jpg');
         */
    }
}

@media (max-width: 768px) and (orientation: portrait) {
    .hero-section {
        min-height: 35vh;
        /* Adjust background to focus on the main content area */
        background-position: center 30%;
    }
}

/* Landscape mobile - shorter hero */
@media (max-width: 896px) and (orientation: landscape) {
    .hero-section {
        min-height: 70vh;
    }
}

/* Tablet Portrait */
@media (min-width: 577px) and (max-width: 991px) {
    .hero-section {
        min-height: 45vh;
    }
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-hero);
}

.hero-content {
    position: relative;
    z-index: 2;
}

.min-vh-50 {
    min-height: 50vh;
}

/* ============ Money Rain Effect ============ */
.money-rain {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}

/* Chinese Gold Yuanbao (元宝) with Image */
.yuanbao {
    position: absolute;
    top: -80px;
    width: 60px;
    transform: scale(var(--scale, 1));
    animation: yuanbaoFall linear forwards;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

.yuanbao img {
    width: 100%;
    height: auto;
    display: block;
}

/* USD Dollar Bill with Image */
.dollar-bill {
    position: absolute;
    top: -100px;
    width: 80px;
    transform: scale(var(--scale, 1));
    animation: billFall linear forwards;
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.4));
}

.dollar-bill img {
    width: 100%;
    height: auto;
    display: block;
}

/* Yuanbao Animation */
@keyframes yuanbaoFall {
    0% {
        transform: translateY(0) translateX(0) rotateY(0deg) rotateZ(0deg) scale(calc(var(--scale, 1) * 0.3));
        opacity: 0;
    }
    5% {
        opacity: 1;
        transform: translateY(5vh) translateX(calc(var(--sway, 30px) * 0.2)) rotateY(45deg) rotateZ(10deg) scale(var(--scale, 1));
    }
    25% {
        transform: translateY(25vh) translateX(calc(var(--sway, 30px) * -0.5)) rotateY(180deg) rotateZ(-15deg) scale(var(--scale, 1));
    }
    50% {
        transform: translateY(50vh) translateX(var(--sway, 30px)) rotateY(360deg) rotateZ(20deg) scale(var(--scale, 1));
    }
    75% {
        transform: translateY(75vh) translateX(calc(var(--sway, 30px) * -0.3)) rotateY(540deg) rotateZ(-10deg) scale(calc(var(--scale, 1) * 0.95));
    }
    90% {
        opacity: 0.9;
    }
    100% {
        transform: translateY(110vh) translateX(calc(var(--sway, 30px) * 0.5)) rotateY(720deg) rotateZ(5deg) scale(calc(var(--scale, 1) * 0.8));
        opacity: 0;
    }
}

/* Dollar Bill Animation - flutter effect */
@keyframes billFall {
    0% {
        transform: translateY(0) translateX(0) rotateZ(0deg) rotateX(0deg) scale(calc(var(--scale, 1) * 0.5));
        opacity: 0;
    }
    5% {
        opacity: 1;
        transform: translateY(5vh) translateX(calc(var(--sway, 40px) * 0.3)) rotateZ(15deg) rotateX(30deg) scale(var(--scale, 1));
    }
    20% {
        transform: translateY(20vh) translateX(calc(var(--sway, 40px) * -0.6)) rotateZ(-20deg) rotateX(-20deg) scale(var(--scale, 1));
    }
    35% {
        transform: translateY(35vh) translateX(calc(var(--sway, 40px) * 0.8)) rotateZ(25deg) rotateX(25deg) scale(var(--scale, 1));
    }
    50% {
        transform: translateY(50vh) translateX(calc(var(--sway, 40px) * -0.4)) rotateZ(-15deg) rotateX(-15deg) scale(var(--scale, 1));
    }
    65% {
        transform: translateY(65vh) translateX(calc(var(--sway, 40px) * 0.5)) rotateZ(20deg) rotateX(10deg) scale(calc(var(--scale, 1) * 0.95));
    }
    80% {
        transform: translateY(80vh) translateX(calc(var(--sway, 40px) * -0.2)) rotateZ(-10deg) rotateX(-5deg) scale(calc(var(--scale, 1) * 0.9));
    }
    90% {
        opacity: 0.85;
    }
    100% {
        transform: translateY(115vh) translateX(var(--sway, 40px)) rotateZ(5deg) rotateX(0deg) scale(calc(var(--scale, 1) * 0.85));
        opacity: 0;
    }
}

/* Variation effects */
.yuanbao:nth-child(5n) {
    filter: drop-shadow(0 5px 15px rgba(255, 215, 0, 0.6));
}

.yuanbao:nth-child(3n) {
    filter: drop-shadow(0 4px 12px rgba(255, 200, 0, 0.5));
}

/* Animation classes */
.animate-fade-in {
    animation: fadeInUp 0.8s ease forwards;
}

.animate-fade-in-delay {
    animation: fadeInUp 0.8s ease 0.2s forwards;
    opacity: 0;
}

.animate-fade-in-delay-2 {
    animation: fadeInUp 0.8s ease 0.4s forwards;
    opacity: 0;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============ Navbar ============ */
.navbar {
    box-shadow: var(--shadow-soft);
}

.navbar-brand {
    font-size: 1.5rem;
}

.cart-badge {
    font-size: 0.65rem;
    transform: translate(-50%, -50%) !important;
}

/* ============ Product Cards ============ */
.product-card {
    border: none;
    border-radius: 15px;
    overflow: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow-soft);
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-hover);
}

.product-image-wrapper {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.product-card:hover .product-image {
    transform: scale(1.1);
}

.product-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: #dee2e6;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.out-of-stock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.low-stock-badge {
    position: absolute;
    top: 10px;
    right: 10px;
}

.product-card .card-body {
    padding: 1.25rem;
}

.product-card .card-title {
    font-weight: 600;
    color: var(--dark);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============ Custom Primary Color Override ============ */
.navbar-primary {
    background-color: var(--primary-color) !important;
}

.btn-primary-custom {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transition: var(--transition);
}

.btn-primary-custom:hover {
    background-color: var(--primary-color-dark);
    border-color: var(--primary-color-dark);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(13, 7, 77, 0.4);
}

.btn-outline-primary-custom {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-outline-primary-custom:hover,
.btn-outline-primary-custom.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.text-primary-custom {
    color: var(--primary-color) !important;
}

.bg-primary-custom {
    background-color: var(--primary-color) !important;
}

/* ============ Buttons ============ */
.btn-danger {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transition: var(--transition);
}

.btn-danger:hover {
    background: var(--primary-color-dark);
    border-color: var(--primary-color-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(13, 7, 77, 0.4);
}

.btn-warning {
    background: var(--gold);
    border-color: var(--gold);
    color: #000;
}

.btn-warning:hover {
    background: var(--gold-dark);
    border-color: var(--gold-dark);
}

.add-to-cart-btn {
    border-radius: 25px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.add-to-cart-btn:active {
    transform: scale(0.95);
}

/* ============ Music Toggle Button ============ */
.btn-music {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1001;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(13, 7, 77, 0.9);
    border: 2px solid #ffc107;
    color: white;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-music:hover {
    transform: scale(1.1);
    background: var(--primary-color);
}

.btn-music.playing {
    animation: pulse-music 1.5s ease-in-out infinite;
}

@keyframes pulse-music {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(13, 7, 77, 0.4);
    }
    50% {
        box-shadow: 0 4px 25px rgba(255, 193, 7, 0.6);
    }
}

/* ============ Floating Contact Buttons ============ */
.floating-buttons {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.floating-buttons .btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: var(--transition);
}

.floating-buttons .btn:hover {
    transform: scale(1.1);
}

.btn-whatsapp {
    background-color: #25D366;
    border-color: #25D366;
    color: white;
}

.btn-whatsapp:hover {
    background-color: #128C7E;
    border-color: #128C7E;
    color: white;
}

.btn-wechat {
    background-color: #07C160;
    border-color: #07C160;
    color: white;
}

.btn-wechat:hover {
    background-color: #059B4D;
    border-color: #059B4D;
    color: white;
}

/* ============ Cart Page ============ */
.quantity-control .form-control {
    border-left: none;
    border-right: none;
}

.quantity-control .btn {
    border-radius: 0;
}

.quantity-control .btn:first-child {
    border-radius: 5px 0 0 5px;
}

.quantity-control .btn:last-child {
    border-radius: 0 5px 5px 0;
}

/* ============ Checkout Page ============ */
.delivery-option {
    padding: 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.delivery-option:hover {
    border-color: var(--primary-color);
    background-color: var(--light-bg);
}

.delivery-option input:checked + label {
    color: var(--primary-color);
}

.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* ============ Order Complete ============ */
.success-checkmark {
    animation: scaleIn 0.5s ease;
}

@keyframes scaleIn {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* ============ Category Filter ============ */
.category-filter.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.btn-outline-danger {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-outline-danger:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* ============ Footer ============ */
footer {
    background: var(--dark) !important;
}

footer a:hover {
    color: var(--gold) !important;
}

/* ============ Cards General ============ */
.card {
    border: none;
    border-radius: 15px;
}

.card-header {
    border-bottom: 1px solid #f0f0f0;
    background: white;
    border-radius: 15px 15px 0 0 !important;
}

/* ============ Toast ============ */
.toast {
    border-radius: 10px;
}

/* ============ Responsive ============ */
@media (max-width: 768px) {
    .hero-section h1 {
        font-size: 2rem;
    }
    
    .floating-buttons {
        bottom: 20px;
        right: 20px;
    }
    
    .floating-buttons .btn {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
    
    .product-card .card-body {
        padding: 1rem;
    }
    
    .category-filter {
        font-size: 0.85rem;
        padding: 0.375rem 0.75rem;
    }
    
    /* Smaller money rain elements on mobile */
    .yuanbao {
        width: 40px;
    }
    
    .dollar-bill {
        width: 50px;
    }
    
    /* Smaller firework explosions on mobile */
    .spark {
        width: 4px;
        height: 4px;
    }
    
    .spark::after {
        width: 8px;
        height: 8px;
    }
}

/* Extra small devices */
@media (max-width: 576px) {
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .product-card .card-title {
        font-size: 0.9rem;
    }
    
    .product-card .h5 {
        font-size: 1rem;
    }
    
    .add-to-cart-btn {
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
    }
    
    /* Even smaller animation elements */
    .yuanbao {
        width: 30px;
    }
    
    .dollar-bill {
        width: 40px;
    }
    
    /* Reduce number of sparks visually */
    .firework-container {
        opacity: 0.85;
    }
}

/* ============ Loading Spinner ============ */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============ Special Effects ============ */
/* Sparkle effect for festive feel */
.sparkle {
    position: relative;
}

.sparkle::after {
    content: '✨';
    position: absolute;
    top: -10px;
    right: -10px;
    animation: twinkle 1.5s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

/* ============ Chinese New Year Theme Accents ============ */
.festive-border {
    border: 3px solid;
    border-image: linear-gradient(45deg, rgb(13, 7, 77), #ffc107, rgb(13, 7, 77)) 1;
}

/* Price styling */
.h5.text-danger {
    font-weight: 700;
    color: var(--primary-color) !important;
}

.text-danger {
    color: var(--primary-color) !important;
}

/* ============ Firework Shooting Animation ============ */
.firework-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}

.firework {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    animation: fireworkShoot linear forwards;
}

.firework-trail {
    position: absolute;
    width: 2px;
    height: 20px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.8), transparent);
    border-radius: 50%;
    animation: trailFade 0.3s linear forwards;
}

.spark {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: sparkExplode ease-out forwards;
}

@keyframes fireworkShoot {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(calc(-1 * var(--shoot-height, 300px)));
        opacity: 1;
    }
}

@keyframes trailFade {
    0% {
        opacity: 0.8;
        transform: scaleY(1);
    }
    100% {
        opacity: 0;
        transform: scaleY(0.5);
    }
}

@keyframes sparkExplode {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--spark-x, 50px), var(--spark-y, 50px)) scale(0);
        opacity: 0;
    }
}

/* Spark glow effect */
.spark::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    background: inherit;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    filter: blur(4px);
    opacity: 0.6;
}
