/* CLS Prevention - Reserve space for key elements */
.cocktail-header h1 {
    /* Remove fixed height, use natural sizing with padding */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(2rem, 5vw, 3em);
    margin: 0 0 1rem 0;
    padding: 1rem 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    /* Prevent font load shifts */
    font-display: swap;
}

.tabs {
    /* Remove fixed height, use natural sizing */
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 2rem 0;
    gap: 10px;
    /* Add min-height for stability */
    min-height: 50px;
}

.filters {
    /* Use auto height with proper spacing */
    background: rgba(255,255,255,0.95);
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 1;
    /* Prevent layout shift from content changes */
    contain: layout;
}

/* Fixed drinks grid with stable layout */
.drinks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
    /* Stable grid container */
    contain: layout;
    /* Reserve minimum space to prevent collapse */
    min-height: 100px;
}

/* Better handling of empty state */
.drinks-grid:empty {
    min-height: 0;
    margin-bottom: 0;
}

/* Skeleton loading state to prevent shifts */
.drinks-grid.loading {
    min-height: 400px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    background-size: 200px 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

/* Limit grid height when there are few items */
.drinks-grid:has(> .drink-card:nth-child(-n+3)) {
    min-height: auto;
    margin-bottom: 20px;
}

.cocktail-main {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%); /* Dark blue-gray gradient */
    /* Alternative options you can try:
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%); - Blue gradient
    background: linear-gradient(135deg, #134e5e 0%, #71b280 100%); - Teal to green
    background: linear-gradient(135deg, #333333 0%, #555555 100%); - Gray gradient
    background: #2c3e50; - Solid dark blue-gray
    background: #1a252f; - Solid dark navy
    */
    min-height: 100vh;
    color: #333;
    padding-top: 100px; /* Account for fixed navigation */
}

.cocktail-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    /* CLS Fix: Add container isolation */
    contain: layout style;
    /* Reserve minimum height to prevent container collapse */
    min-height: calc(100vh - 140px);
}

.cocktail-header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
    /* CLS Fix: Reserve exact space for header */
    contain: layout;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.subtitle {
    font-size: 1.2em;
    opacity: 0.9;
    margin: 0;
    padding: 0.5rem 0;
    line-height: 1.4;
}

.tab {
    padding: 12px 30px;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 25px;
    color: white;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.tab.active {
    background: rgba(255,255,255,0.9);
    color: #333;
    transform: scale(1.05);
}

.filter-section {
    margin-bottom: 20px;
}

.filter-label {
    font-weight: bold;
    margin-bottom: 10px;
    display: block;
    color: #555;
}

/* FIXED: Force dropdown to open downward */
.ingredient-select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    background: white;
    transition: border-color 0.3s ease;
    position: relative;
    z-index: 1;
    /* Force dropdown direction */
    -webkit-appearance: menulist;
    -moz-appearance: menulist;
    appearance: menulist;
}

/* Ensure dropdown options appear below the select */
.ingredient-select option {
    background: white;
    color: #333;
    padding: 8px;
}

.ingredient-select:focus {
    outline: none;
    border-color: #667eea;
    z-index: 2;
}

/* Container positioning to prevent upward dropdown */
.filter-section {
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
}

.ingredient-help {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
}

/* Better sizing for selected ingredients container */
.selected-ingredients {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    /* CLS Fix: Stable height for ingredients container */
    min-height: 40px;
    max-height: 120px; /* Limit height when many ingredients */
    overflow-y: auto; /* Scroll if too many ingredients */
    contain: layout; /* Prevent layout shifts */
}

.ingredient-tag {
    background: #667eea;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.remove-ingredient {
    cursor: pointer;
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-mode {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    border: none;
    padding: 0;
}

.filter-mode legend {
    color: #555;
    font-weight: bold;
    margin-bottom: 10px;
}

.filter-mode label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
}

.drink-card {
    background: rgba(255,255,255,0.95);
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
    /* CLS Fix: Reserve space for cards */
    min-height: 120px;
    contain: layout;
}

.drink-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.2);
}

.drink-name {
    font-size: 1.4em;
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
}

.drink-ingredients {
    font-size: 0.9em;
    color: #666;
    line-height: 1.4;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 10000; /* Higher than navigation */
    backdrop-filter: blur(5px);
}

/* FIXED: Modal content with proper scrolling restored */
.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 20px;
    max-width: 800px;
    width: 90%;
    max-height: 85vh;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    z-index: 10001;
    overflow: hidden; /* Hide overflow on container */
}

/* Scrollable content area inside modal with better styling */
.modal-scroll-content {
    padding: 30px;
    max-height: calc(85vh - 40px); /* Account for padding */
    overflow-y: auto;
    
    /* Custom scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 #f7fafc;
}

/* Webkit scrollbar styling for modal content */
.modal-scroll-content::-webkit-scrollbar {
    width: 6px;
}

.modal-scroll-content::-webkit-scrollbar-track {
    background: #f7fafc;
    border-radius: 3px;
}

.modal-scroll-content::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
    transition: background 0.2s ease;
}

.modal-scroll-content::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 30px;
    cursor: pointer;
    color: #666;
    transition: color 0.3s ease;
    z-index: 10002; /* Above modal content */
    background: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
}

.close:hover {
    color: #333;
    background: #f0f0f0;
}

.modal-drink-name {
    font-size: 2em;
    font-weight: bold;
    margin-bottom: 20px;
    color: #333;
    padding-right: 40px; /* Make room for close button */
}

.modal-section {
    margin-bottom: 25px;
}

.modal-section h3 {
    font-size: 1.3em;
    margin-bottom: 10px;
    color: #667eea;
    border-bottom: 2px solid #667eea;
    padding-bottom: 5px;
}

.ingredients-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.ingredient-item {
    background: #f0f0f0;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 14px;
    color: #555;
}

.instructions-list {
    list-style: none;
    counter-reset: step-counter;
}

.instructions-list li {
    counter-increment: step-counter;
    margin-bottom: 10px;
    padding-left: 30px;
    position: relative;
    line-height: 1.5;
}

.instructions-list li::before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 0;
    background: #667eea;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.video-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.video-container {
    text-align: center;
}

.video-container h4 {
    margin-bottom: 10px;
    color: #555;
}

iframe {
    width: 100%;
    height: 200px;
    border-radius: 10px;
    border: none;
}
.logo-text {
    font-size: 1.5rem;
    font-weight: bold;
    color: inherit;
}
.no-results {
    text-align: center;
    color: white;
    font-size: 1.2em;
    margin-top: 50px;
    opacity: 0.8;
    /* CLS Fix: Reserve space for no-results */
    min-height: 150px;
    contain: layout;
}

.no-results h3 {
    margin-bottom: 15px;
    font-size: 1.5em;
}

.no-results p {
    margin-bottom: 10px;
}

.clear-filters {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 15px;
    transition: background 0.3s ease;
}

.clear-filters:hover {
    background: #c0392b;
}

/* SEO-friendly additions */
.search-section {
    margin: 20px 0;
    text-align: center;
    /* CLS Fix: Reserve space for search section */
    min-height: 80px;
    contain: layout;
}

.search-section h2 {
    color: white;
    font-size: 1.5em;
    margin-bottom: 15px;
}

.search-description{
    color: white;
    font-size: 1.5em;
    margin-bottom: 15px;
}

.popular-ingredients {
    background: rgba(255,255,255,0.1);
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    text-align: center;
    /* CLS Fix: Reserve space for popular ingredients */
    min-height: 100px;
    contain: layout;
}

.popular-ingredients h3 {
    color: white;
    margin-bottom: 15px;
}

.ingredient-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    /* CLS Fix: Minimum height for chips container */
    min-height: 50px;
}

.ingredient-chip {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    font-size: 14px;
}

.ingredient-chip:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

.ingredient-chip:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Breadcrumb styling */
.breadcrumb {
    color: rgba(255,255,255,0.8);
    margin-bottom: 20px;
    font-size: 14px;
}

.breadcrumb a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

/* How to Use section styling */
.how-to-use {
    background: rgba(255,255,255,0.95);
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
    /* CLS Fix: Reserve space for how-to-use section */
    contain: layout;
    min-height: 400px;
}

.how-to-use h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.how-to-use-content {
    color: #555;
    line-height: 1.6;
}

.how-to-use-content p {
    margin-bottom: 10px;
}

.how-to-use-content strong {
    color: #333;
}

.how-to-use h3 {
    color: #667eea;
    margin: 25px 0 15px 0;
    font-size: 1.2em;
}

.how-to-use ul {
    margin-left: 20px;
    margin-bottom: 20px;
}

.how-to-use li {
    margin-bottom: 5px;
}

/* MOVED FROM INLINE STYLES - Footer Styles */
.site-footer {
    background: #2d2b29;
    color: white;
    padding: 2rem 0;
    margin-top: 3rem;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    text-align: center;
}

.footer-container p {
    margin-bottom: 1rem;
}

.footer-container p:last-child {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: #999;
}

.footer-nav {
    margin: 0 1rem;
    color: #ccc;
    text-decoration: none;
}

.footer-nav:hover {
    text-decoration: underline;
}

/* Critical CSS optimizations */
body { 
    font-family: 'Times New Roman', Times, serif; 
    font-display: swap; 
    margin: 0;
    padding: 0;
    padding-top: 100px;
}

/* Base typography to prevent font shifts */
h1, h2, h3, h4, h5, h6 {
    font-display: swap;
    line-height: 1.2;
}

p {
    line-height: 1.6;
}

@media (max-width: 768px) {
    .cocktail-main {
        padding-top: 80px;
    }
    
    .video-section {
        grid-template-columns: 1fr;
    }
    
    .cocktail-header h1 {
        font-size: 2em;
    }
    
    .cocktail-header {
        min-height: 100px;
    }
    
    .drinks-grid {
        grid-template-columns: 1fr;
        min-height: 300px;
    }
    
    .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 10px;
    }
    
    .modal-scroll-content {
        padding: 20px;
        max-height: calc(90vh - 40px);
    }
    
    .filter-mode {
        flex-direction: column;
        gap: 10px;
    }
    
    .ingredient-chips {
        justify-content: flex-start;
    }
    
    .tabs {
        flex-direction: column;
        align-items: center;
        height: auto;
        padding: 10px 0;
        min-height: 120px;
    }
    
    .tab {
        width: 200px;
        text-align: center;
    }

    .filters {
        min-height: 300px;
    }
    
    .how-to-use {
        min-height: 350px;
    }
    
    .cocktail-container {
        min-height: calc(100vh - 100px);
    }
}

/* Additional accessibility improvements */
.tab:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.ingredient-select:focus {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

.drink-card:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: "Loading...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
}