:root {
    --primary-color: #ff9f43;
    --primary-hover: #ff7f0e;
    --secondary-color: #1dd1a1;
    --dark-bg: #121212;
    --darker-bg: #0a0a0a;
    --card-bg: #1e1e1e;
    --text-color: #e0e0e0;
}

html, body {
    height: 100%;
    margin: 0;
    -webkit-tap-highlight-color: transparent; /* PWA Optimization */
    overflow-x: hidden; /* CRITICAL: Prevent horizontal overflow from decorative elements */
    width: 100%;
    position: relative;
}

body {
    background-color: var(--dark-bg);
    color: var(--text-color);
    font-family: 'Outfit', sans-serif;
}

/* Sfondo Pattern Dinamico */
body.bg-pattern {
    background-image: url("/static/images/kitchen_pattern.png");
    background-repeat: repeat;
    background-attachment: fixed;
    background-size: 700px;
    background-position: center;
    background-color: #050505;
}

body.bg-pattern::before {
    content: "";
    position: fixed;
    top: 0; left: 0; 
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.2); /* Overlay quasi invisibile, solo per ammorbidire */
    z-index: -1;
    pointer-events: none;
}

/* Navbar Fluttuante Glassmorphism */
.navbar-floating {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    width: 94%;
    max-width: 1400px;
    background: rgba(10, 10, 10, 0.6) !important; /* Più trasparente */
    backdrop-filter: blur(25px) saturate(160%);
    -webkit-backdrop-filter: blur(25px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.08); /* Bordo più sottile */
    border-radius: 5rem; /* Più arrotondato (pillola totale) */
    padding: 0.5rem 2rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    z-index: 2000;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 991.98px) {
    .navbar-floating {
        top: 0.5rem;
        width: 96%;
        padding: 0.4rem 1rem;
        border-radius: 2rem;
    }
}

/* Trasparenze forzate quando il pattern è attivo */
body.bg-pattern .bg-darker,
body.bg-pattern .bg-gradient-dark,
body.bg-pattern .bg-gradient-darker,
body.bg-pattern .section-left,
body.bg-pattern .section-right,
body.bg-pattern .content-container,
body.bg-pattern .full-screen-app,
body.bg-pattern .app-content {
    background-color: transparent !important;
    background: transparent !important;
}

body.bg-pattern .bg-dark-card {
    background-color: rgba(25, 25, 25, 0.8) !important;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}



/* Base Utilities */
.z-1100 { z-index: 1100 !important; }
.pointer-events-none { pointer-events: none !important; }
.pointer-events-auto { pointer-events: auto !important; }


/* Utilities */
.bg-darker {
    background-color: var(--darker-bg) !important;
}

.bg-gradient-dark {
    background: radial-gradient(circle at center, #1a1a1a 0%, var(--dark-bg) 100%) !important;
}

.bg-gradient-darker {
    background: radial-gradient(circle at center, var(--dark-bg) 0%, var(--darker-bg) 100%) !important;
}


.bg-dark-card {
    background-color: var(--card-bg) !important;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

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

.text-gradient {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.text-xs, .x-small-text {
    font-size: 0.75rem !important;
}

.ls-1 {
    letter-spacing: 1px;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover)) !important;
    border: none !important;
    color: #000 !important;
    font-weight: 700 !important;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 159, 67, 0.3);
}

.btn-outline-light {
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
    backdrop-filter: blur(10px);
    color: #fff !important;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary-color));
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 159, 67, 0.5);
}

.btn-outline-light:hover {
    color: var(--darker-bg);
}

.btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Footer */
.app-footer {
    flex: 0 0 auto;
    background-color: rgba(10, 10, 10, 0.9);
    backdrop-filter: blur(10px);
    border-top: none;
    z-index: 1030;
}

.hover-link:hover {
    color: var(--primary-color) !important;
    transition: color 0.3s ease;
}

/* Layout: Flexbox App Shell */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    background: transparent !important;
    position: relative;
}

@media (min-width: 992px) {
    .app-shell {
        height: 100vh;
        overflow: hidden;
    }
}

.navbar {
    flex: 0 0 auto;
    background-color: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(15px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    min-height: 80px;
    padding-top: 0.8rem;
    padding-bottom: 0.8rem;
    z-index: 1100;
}

.app-main {
    flex: 1 1 auto;
    position: relative;
    display: flex;
    flex-direction: column;
    padding-top: 6.5rem;
}

@media (min-width: 992px) {
    .app-main {
        overflow: hidden;
    }
}

@media (max-width: 991.98px) {
    .app-main {
        padding-top: 5.5rem;
        overflow: visible !important;
    }
}

.app-content {
    flex: 1 1 auto;
    position: relative;
    padding-bottom: 2rem; /* Margine di sicurezza base */
}

@media (min-width: 992px) {
    .app-content {
        overflow-y: auto;
        overflow-x: hidden;
    }
}

@media (max-width: 991.98px) {
    .app-content {
        padding-bottom: 6rem; /* Più spazio per il footer fisso su mobile */
    }
}

@media (max-width: 991.98px) {
    .app-content {
        overflow: visible !important;
    }
}

.section-left,
.section-right {
    min-height: 400px;
    background-color: transparent !important; /* Forza trasparenza per continuità sfondo */
    display: flex;
    flex-direction: column;
}

@media (min-width: 992px) {
    .section-left,
    .section-right {
        height: 100%; /* Fill the app-content space */
        border-right: none; /* Rimosso bordo per evitare stacchi visivi */
        border-bottom: none;
        overflow-y: auto;
    }
}


.flash-container {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1050;
    width: 100%;
    max-width: 600px;
    pointer-events: none;
}

@media (max-width: 991.98px) {
    .flash-container {
        top: 0.5rem;
    }
}

@media (max-width: 991.98px) {
    .navbar-collapse {
        background-color: rgba(15, 15, 15, 0.95);
        backdrop-filter: blur(25px);
        margin: 1rem -1.5rem -0.75rem -1.5rem; /* Si estende fino ai bordi del contenitore fluttuante pivotato */
        padding: 1.5rem;
        border-radius: 0 0 2rem 2rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .navbar-nav .nav-link {
        padding: 0.85rem;
        text-align: center;
        font-size: 1.05rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
    
    .navbar-nav .nav-link.active {
        color: var(--primary-color) !important;
        background-color: rgba(255, 159, 67, 0.05);
        border-radius: 0.75rem;
    }
    
    .navbar-nav .nav-item:last-child .nav-link {
        border-bottom: none;
    }
}



/* Decorative */
.decorative-circle {
    position: absolute;
    width: 1000px;
    height: 1000px;
    background: radial-gradient(circle, rgba(255, 159, 67, 0.15) 0%, rgba(0, 0, 0, 0) 70%);
    top: -400px;
    left: -300px;
    border-radius: 50%;
    z-index: 0;
    pointer-events: none;
    filter: blur(50px);
}

@media (max-width: 767.98px) {
    .decorative-circle {
        display: none !important;
    }
    .landing-hero {
        overflow: hidden !important;
    }
}

.decorative-circle-right {
    top: -200px;
    left: auto;
    right: -200px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.04) 0%, rgba(0, 0, 0, 0) 70%);
}


.decorative-circle-secondary {
    background: radial-gradient(circle, rgba(29, 209, 161, 0.08) 0%, rgba(0, 0, 0, 0) 70%);
}


/* Cards & Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: var(--darker-bg);
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

.shadow-hover {
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.shadow-hover:hover {
    box-shadow: 0 10px 20px rgba(255, 159, 67, 0.2);
}

.shadow-2xl {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.hover-card {
    transition: transform 0.3s ease;
}

.hover-card:hover {
    transform: translateY(-5px);
}

/* Animation */
@keyframes pulse {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 2s infinite;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Forms */
/* Form Controls & Inputs */
.form-control, .form-select {
    background-color: rgba(20, 20, 20, 0.4) !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    color: #fff !important;
    transition: all 0.2s ease !important;
}

.input-group .btn {
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    border-left: none !important;
}

body.bg-pattern .form-control,
body.bg-pattern .form-select {
    background-color: rgba(10, 10, 10, 0.7) !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.2);
    background-color: rgba(30, 30, 30, 0.6) !important;
}

/* Dynamic Ingredients */
.border-dashed {
    border: 2px dashed #444;
}

.border-dashed:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.animate-pulse-once {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#ingredientsContainer input {
    background-color: #2a2a2a !important;
    color: white !important;
}

#ingredientsContainer input::placeholder {
    color: #666;
}

/* Custom Toast Styles */
.toast {
    background-color: rgba(30, 30, 30, 0.95) !important;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
}

.toast .btn-close-white {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Ottimizzazione visiva per schermi laptop ~14 pollici */
@media (min-width: 992px) and (max-width: 1440px) {
    html {
        font-size: 90%;
    }
}

/* Mobile Optimizations (PWA) */
@media (max-width: 767.98px) {
    .display-1 { font-size: 2.8rem !important; }
    .display-2 { font-size: 2.4rem !important; }
    .display-3 { font-size: 2.1rem !important; }
    .display-4 { font-size: 1.8rem !important; }
    
    h1 { font-size: 2rem !important; }
    h2 { font-size: 1.7rem !important; }
    
    .landing-hero {
        padding-top: 1.5rem !important; /* Rimosso eccesso (già gestito da app-main) */
        padding-bottom: 2rem !important;
        min-height: auto !important;
    }
    
    .landing-hero .display-2 {
        line-height: 1.1;
        margin-bottom: 2rem !important;
        letter-spacing: 0 !important;
    }

    /* Miglioramento leggibilità testo su pattern */
    .landing-hero p.lead {
        opacity: 1 !important;
        color: #fff !important;
        font-weight: 500;
        text-shadow: 0 2px 10px rgba(0,0,0,0.5);
    }

    .landing-hero .gap-3 {
        gap: 1.5rem !important;
    }

    .app-main {
        padding-top: 6rem !important; /* Offset ideale per navbar fluttuante (0.5rem + 5.5rem height) */
    }

    .hero-image-card {
        margin-top: 2rem;
    }

    .cookie-banner {
        border-top-left-radius: 1.5rem;
        border-top-right-radius: 1.5rem;
        padding-bottom: env(safe-area-inset-bottom) !important;
    }

    .cookie-banner p {
        font-size: 0.8rem !important;
        margin-bottom: 1rem !important;
    }

    .navbar-floating {
        padding: 0.4rem 0.8rem;
    }

    .font-heading {
        letter-spacing: 0 !important;
    }
}

.cursor-pointer {
    cursor: pointer;
}

/* Custom Popover Styles */
.popover {
    background-color: rgba(30,30,30,0.95) !important;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,159,67,0.3);
    border-radius: 1rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.popover-body {
    color: #e0e0e0 !important;
    font-size: 0.85rem;
    padding: 1rem;
}
.bs-popover-top > .popover-arrow::after {
    border-top-color: rgba(30, 30, 30, 0.95) !important;
}