/* ============================================================================
   FILE: components.css
   DESCRIPTION: Reusable UI Elements and Overlays.
   Contains styles for Search Dropdown, Icon Buttons, Global Toast 
   Notifications, Custom Modals, and Reveal Animations.
   ============================================================================ */

/* --- 1. NAV ACTIONS (Icons & Cart Badges) --- */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 15px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    transition: color var(--transition-fast), transform var(--transition-fast);
}

.icon-btn:hover {
    color: var(--primary-gold);
    transform: translateY(-2px);
}

.cart-badge {
    position: absolute;
    top: 0px;
    right: -1px;
    background-color: var(--primary-gold);
    color: var(--text-light);
    font-size: 0.65rem;
    font-weight: bold;
    line-height: 1;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    pointer-events: none;
}

/* Subtle pop animation when badge count changes */
.cart-badge:not(:empty) {
    animation: badgePop 0.3s ease;
}

@keyframes badgePop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* --- 2. EXPANDABLE SEARCH BAR & RESULTS --- */
.search-wrapper {
    display: flex;
    align-items: center;
    position: relative;
}

.search-input {
    width: 0;
    opacity: 0;
    border: none;
    border-bottom: 1px solid var(--text-main);
    background: transparent;
    padding: 5px 0;
    font-size: 0.9rem;
    color: var(--text-main);
    transition: width 0.4s cubic-bezier(0.2, 0.8, 0.3, 1), opacity 0.4s ease, padding 0.4s ease;
    outline: none;
}

.search-wrapper.active .search-input {
    width: 180px;
    opacity: 1;
    padding: 5px 10px;
    margin-right: 10px;
}

.search-input::placeholder {
    color: #888888;
}

.search-results {
    position: absolute;
    top: 130%;
    right: 0;
    width: 320px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px); 
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: var(--card-radius);
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px);
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.3, 1);
    max-height: 400px;
    overflow-y: auto;
    z-index: 2000;
}

.search-wrapper.active .search-results.has-results {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    text-align: left;
    transition: background 0.3s ease;
}

.search-result-item:hover { background: var(--bg-body); }
.search-result-img { width: 50px; height: 50px; border-radius: var(--btn-radius); object-fit: cover; margin-right: 15px; }
.search-result-info p { font-size: 0.8rem; color: var(--text-sub); }
.close-search-btn { display: none; }
/* --- SEARCH BADGES (PREMIUM TOP-ALIGNED LOOK) --- */
.search-result-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.search-result-info h4 {
    font-size: 0.92rem;
    line-height: 1.3;
    margin-bottom: 3px;
    color: var(--text-main);
    text-align: left;
}

.search-badge {
    display: inline-block;
    white-space: nowrap;
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 2px 6px;
    border-radius: 3px;
    margin-bottom: 4px; /* Visual gap between badge and product title */
}

.search-badge.sold-out {
    background-color: #777777;
    color: #ffffff;
}

.search-badge.coming-soon {
    background-color: var(--primary-gold);
    color: #ffffff;
}

/* --- 3. GLOBAL ALERTS & NOTIFICATIONS --- */
.global-notifications-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none; 
}

.premium-toast {
    background-color: var(--text-main); 
    color: var(--bg-body); 
    padding: 14px 28px;
    border-radius: var(--btn-radius);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    border-bottom: 2px solid var(--primary-gold);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.3, 1);
    pointer-events: auto; 
    text-align: center;
    white-space: nowrap;
}

.premium-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* --- 4. SCROLL REVEAL ANIMATIONS --- */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease-out, transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* --- 5. CUSTOM MODAL (e.g., Cart Clear Popup) --- */
.custom-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
    display: flex; align-items: center; justify-content: center;
    z-index: 99999; opacity: 0; visibility: hidden; transition: all 0.3s ease;
}
.custom-modal-overlay.show { opacity: 1; visibility: visible; }

.custom-modal {
    background: var(--text-light); padding: 35px 30px; 
    border-radius: var(--card-radius);
    max-width: 380px; width: 90%; text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    transform: translateY(20px); transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.custom-modal-overlay.show .custom-modal { transform: translateY(0); }

.modal-icon { margin-bottom: 15px; display: flex; justify-content: center; }
.modal-title { font-size: 1.25rem; color: var(--text-main); margin-bottom: 10px; }
.modal-desc { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 25px; line-height: 1.5; }

.modal-actions { display: flex; gap: 12px; }
.modal-btn-no, .modal-btn-yes {
    flex: 1; 
    padding: 12px 5px;
    font-size: 0.7rem; 
    font-weight: 600;
    border-radius: var(--btn-radius); 
    cursor: pointer; 
    transition: all 0.3s ease; 
    text-transform: uppercase; 
    letter-spacing: 0.05em;
}

/* Modal Action Buttons */
.modal-btn-no { background: transparent; border: 1px solid #dddddd; color: var(--text-muted); }
.modal-btn-no:hover { background: #f5f5f5; color: var(--text-main); border-color: #aaaaaa; }

.modal-btn-yes { background: var(--text-main); border: 1px solid var(--text-main); color: var(--text-light); }
.modal-btn-yes:hover { background: var(--primary-gold); border-color: var(--primary-gold); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(212, 160, 23, 0.2); }

/* --- 6. MOBILE RESPONSIVENESS (Components) --- */
/* On mobile (<=768px), the search bar transforms into a fullscreen overlay
   with a blurred background, repositioned input, and animated entrance.
   This provides a focused, distraction-free search experience on small screens. */
@media (max-width: 768px) {
    .nav-actions { justify-self: flex-end; margin-left: 0; margin-right: 0; }
    
    /* Search Full-Screen Overrides */
    .search-input { transition: none !important; }
    body.mobile-search-active { overflow: hidden; }
    body.mobile-search-active .search-wrapper { position: static; }
    
    /* Fullscreen background overlay with smooth blur */
    body.mobile-search-active .search-wrapper::before {
        content: ''; 
        position: fixed; 
        top: 0; 
        left: 0;
        width: 100vw; 
        height: 100vh; 
        background: rgba(253, 251, 247, 0.98); 
        backdrop-filter: blur(15px); 
        -webkit-backdrop-filter: blur(15px);
        z-index: 9990; 
        opacity: 0; 
        animation: fadeOverlay 0.3s ease-out forwards;
    }
    
    /* Search Input Box: Sleek underline style matching desktop typography */
    body.mobile-search-active .search-input {
        position: fixed; 
        top: 85px; 
        left: 6%; 
        width: 88% !important;
        background: transparent !important; 
        border: none !important; 
        border-bottom: 1.5px solid var(--text-main) !important; /* Premium dark bottom line */
        border-radius: 0 !important; /* Clean straight line style */
        padding: 10px 0 !important; 
        font-size: 1.15rem !important; /* Slightly reduced font size for modern aesthetic */
        font-weight: 500 !important;
        color: var(--text-main) !important;
        z-index: 9999; 
        opacity: 0; 
        transform: translateY(15px);
        animation: slideUpPremium 0.4s 0.1s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
    }

    /* Active focus state for input line */
    body.mobile-search-active .search-input:focus { 
        border-bottom-color: var(--primary-gold) !important; 
        outline: none !important;
    }

    /* Search Results dropdown position alignment for mobile overlay */
    body.mobile-search-active .search-results {
        position: fixed; 
        top: 150px; 
        left: 6%; 
        width: 88%;
        max-height: calc(100vh - 170px); 
        overflow-y: auto; 
        z-index: 9999;
        background: transparent; 
        border: none; 
        box-shadow: none;
        opacity: 0; 
        visibility: hidden; 
        transform: translateY(15px);
        animation: slideUpPremium 0.4s 0.2s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
    }
    
    .close-search-btn { font-size: 1.5rem; background: none; border: none; color: var(--text-main); cursor: pointer; z-index: 10000; display: none; opacity: 0; }
    body.mobile-search-active .close-search-btn { display: block; position: fixed; top: 25px; right: 25px; animation: fadeOverlay 0.3s 0.2s ease-out forwards; }
    body.mobile-search-active #search-btn { opacity: 0; pointer-events: none; }
    
    @keyframes fadeOverlay { to { opacity: 1; } }
    @keyframes slideUpPremium { to { opacity: 1; visibility: visible; transform: translateY(0); } }
    
    /* Global Toast Mobile Overrides */
    .global-notifications-container { bottom: 25px; width: 90%; }
    .premium-toast { width: 100%; padding: 14px 20px; font-size: 0.85rem; white-space: normal; }
}

/* --- 7. UTILITY COMPONENTS (Close Button) --- */
.close-btn {
    background: transparent; 
    border: none; 
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    transition: color 0.3s ease, transform 0.3s ease;
}

.close-btn:hover {
    color: #EA4335; /* Turns slightly red on hover for a premium feel */
    transform: scale(1.1); /* Slight pop effect */
}