/**
 * CSS Principale "Idee in Cucina"
 * 
 * @author Filippo Bilardo
 * @version 1.0
 */

/* Placeholder per immagini mancanti */
.recipe-placeholder {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border: 2px dashed #dee2e6;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: 0.9rem;
    text-align: center;
    padding: 1rem;
    border-radius: var(--border-radius);
}

.recipe-placeholder::before {
    content: "📷";
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.recipe-placeholder.small {
    min-height: 200px;
}

.recipe-placeholder.medium {
    min-height: 300px;
}

.recipe-placeholder.large {
    min-height: 400px;
}

/* Loading placeholder con animazione */
.image-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ===== VARIABILI CSS ===== */
:root {
    /* Colori */
    --primary-color: #E44D26;
    --secondary-color: #2C3E50;
    --accent-color: #F39C12;
    --text-color: #2C3E50;
    --text-light: #6C757D;
    --background-color: #FAFAFA;
    --white: #FFFFFF;
    --light-gray: #F8F9FA;
    --border-color: #DEE2E6;
    --success-color: #28A745;
    --warning-color: #FFC107;
    --danger-color: #DC3545;
    
    /* Typography */
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Open Sans', sans-serif;
    --font-size-base: 1rem;
    --font-size-sm: 0.875rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-xxl: 3rem;
    
    /* Bordi */
    --border-radius: 0.375rem;
    --border-radius-lg: 0.5rem;
    --border-radius-pill: 50rem;
    
    /* Ombre */
    --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
    
    /* Transizioni */
    --transition: all 0.3s ease;
    --transition-fast: all 0.15s ease;
}

/* ===== RESET E BASE ===== */
* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    color: var(--text-color);
    background-color: var(--background-color);
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--spacing-md);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition-fast);
}

a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
}

/* ===== LAYOUT PRINCIPALE ===== */
.main-content {
    min-height: calc(100vh - 140px);
}

/* ===== HEADER ===== */
.header-main {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
}

.navbar-brand {
    font-family: var(--font-heading);
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--primary-color) !important;
    text-decoration: none;
}

.navbar-brand img {
    flex-shrink: 0;
}

.brand-text {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.navbar-brand:hover {
    text-decoration: none;
}

.navbar-brand:hover .brand-text {
    color: var(--accent-color);
}

/* Logo responsive */
@media (max-width: 768px) {
    .navbar-brand img {
        height: 28px !important;
    }
    
    .brand-text {
        font-size: 1.3rem;
    }
}

@media (max-width: 576px) {
    .navbar-brand img {
        height: 25px !important;
    }
    
    .brand-text {
        font-size: 1.1rem;
    }
}

.nav-link {
    font-weight: 500;
    color: var(--text-color) !important;
    padding: var(--spacing-sm) var(--spacing-md) !important;
    border-radius: var(--border-radius);
    transition: var(--transition-fast);
}

.nav-link:hover,
.nav-link.active {
    background-color: var(--primary-color);
    color: var(--white) !important;
    text-decoration: none;
}

.search-input {
    border-color: var(--border-color);
    min-width: 200px;
}

.search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(228, 77, 38, 0.25);
}

/* ===== HERO SECTION ===== */
.hero-section {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: var(--white);
    padding: var(--spacing-xxl) 0;
    text-align: center;
}

.hero-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    margin-bottom: var(--spacing-lg);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.hero-subtitle {
    font-size: var(--font-size-lg);
    margin-bottom: var(--spacing-xl);
    opacity: 0.9;
}

.hero-search {
    max-width: 600px;
    margin: 0 auto;
}

.hero-search .form-control {
    border: none;
    padding: var(--spacing-lg);
    font-size: var(--font-size-lg);
    border-radius: var(--border-radius-pill);
}

.hero-search .btn {
    padding: var(--spacing-lg) var(--spacing-xl);
    border-radius: var(--border-radius-pill);
    border: none;
    background-color: var(--secondary-color);
    color: var(--white);
    font-weight: 600;
}

.hero-search .btn:hover {
    background-color: var(--accent-color);
    transform: translateY(-2px);
}

/* ===== CARDS RICETTE ===== */
.recipe-card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.recipe-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
}

.recipe-card-img {
    position: relative;
    overflow: hidden;
    height: 200px;
}

.recipe-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.recipe-card:hover .recipe-card-img img {
    transform: scale(1.05);
}

.recipe-difficulty {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-pill);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
}

.recipe-difficulty.facile {
    background-color: var(--success-color);
    color: var(--white);
}

.recipe-difficulty.media {
    background-color: var(--warning-color);
    color: var(--text-color);
}

.recipe-difficulty.difficile {
    background-color: var(--danger-color);
    color: var(--white);
}

.recipe-card-body {
    padding: var(--spacing-lg);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.recipe-card-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--text-color);
    line-height: 1.3;
}

.recipe-card-description {
    color: var(--text-light);
    font-size: var(--font-size-sm);
    margin-bottom: var(--spacing-md);
    flex-grow: 1;
}

.recipe-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--font-size-sm);
    color: var(--text-light);
    border-top: 1px solid var(--border-color);
    padding-top: var(--spacing-sm);
    margin-top: auto;
}

.recipe-time {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.recipe-rating {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

/* ===== RATING STELLE ===== */
.rating {
    display: inline-flex;
    gap: 2px;
}

.star {
    font-size: 1.2rem;
    color: #ddd;
    cursor: pointer;
    transition: var(--transition-fast);
}

.star.filled {
    color: var(--accent-color);
}

.rating:not(.readonly) .star:hover,
.rating:not(.readonly) .star.hover {
    color: var(--accent-color);
    transform: scale(1.1);
}

/* ===== SEZIONI HOMEPAGE ===== */
.section-title {
    font-family: var(--font-heading);
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    text-align: center;
    margin-bottom: var(--spacing-xl);
    color: var(--secondary-color);
    position: relative;
}

.section-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 3px;
    background-color: var(--primary-color);
    margin: var(--spacing-md) auto 0;
    border-radius: var(--border-radius);
}

.popular-recipes {
    padding: var(--spacing-xxl) 0;
    background: var(--white);
}

.recipe-of-day {
    padding: var(--spacing-xxl) 0;
    background: var(--light-gray);
}

.newsletter-section {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    color: var(--white);
    padding: var(--spacing-xxl) 0;
    text-align: center;
}

.newsletter-form .form-control {
    border: none;
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
}

.newsletter-form .btn {
    padding: var(--spacing-md) var(--spacing-xl);
    border: none;
    background-color: var(--accent-color);
    color: var(--text-color);
    font-weight: 600;
    border-radius: var(--border-radius);
}

/* ===== PAGINA RICETTA ===== */
.recipe-header {
    background: var(--white);
    padding: var(--spacing-xl) 0;
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
}

.recipe-title {
    font-size: clamp(1.75rem, 4vw, 3rem);
    color: var(--secondary-color);
    margin-bottom: var(--spacing-md);
}

.recipe-meta-info {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: var(--font-size-sm);
    color: var(--text-light);
}

.meta-item i {
    color: var(--primary-color);
    font-size: var(--font-size-lg);
}

.recipe-content {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
}

.ingredients-list {
    list-style: none;
    padding: 0;
}

.ingredients-list li {
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    padding-left: var(--spacing-lg);
}

.ingredients-list li:before {
    content: '✓';
    position: absolute;
    left: 0;
    top: var(--spacing-sm);
    color: var(--success-color);
    font-weight: bold;
}

.ingredients-list li:last-child {
    border-bottom: none;
}

.procedure-steps {
    counter-reset: step-counter;
}

.procedure-step {
    counter-increment: step-counter;
    margin-bottom: var(--spacing-lg);
    position: relative;
    padding-left: 3rem;
}

.procedure-step:before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 0;
    width: 2rem;
    height: 2rem;
    background-color: var(--primary-color);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: var(--font-size-sm);
}

/* ===== GALLERY IMMAGINI ===== */
.recipe-gallery {
    margin-bottom: var(--spacing-lg);
}

.gallery-main {
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    margin-bottom: var(--spacing-md);
}

.gallery-thumbs {
    display: flex;
    gap: var(--spacing-sm);
    overflow-x: auto;
    padding: var(--spacing-sm) 0;
}

.gallery-thumb {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: var(--border-radius);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition-fast);
}

.gallery-thumb.active {
    border-color: var(--primary-color);
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ===== CONDIVISIONE SOCIAL ===== */
.social-share {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.social-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: var(--transition-fast);
}

.social-btn:hover {
    transform: translateY(-2px);
    text-decoration: none;
}

.social-btn.facebook {
    background-color: #3b5998;
    color: var(--white);
}

.social-btn.whatsapp {
    background-color: #25d366;
    color: var(--white);
}

.social-btn.pinterest {
    background-color: #bd081c;
    color: var(--white);
}

/* ===== FILTRI E RICERCA ===== */
.filters-section {
    background: var(--white);
    padding: var(--spacing-lg);
    border-radius: var(--border-radius-lg);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
}

.filter-group {
    margin-bottom: var(--spacing-md);
}

.filter-label {
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--secondary-color);
}

.filter-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.filter-checkbox {
    display: none;
}

.filter-checkbox-label {
    display: inline-block;
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--light-gray);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-pill);
    cursor: pointer;
    font-size: var(--font-size-sm);
    transition: var(--transition-fast);
}

.filter-checkbox:checked + .filter-checkbox-label {
    background-color: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

/* ===== PAGINAZIONE ===== */
.pagination-custom {
    display: flex;
    justify-content: center;
    margin-top: var(--spacing-xl);
}

.pagination-custom .page-link {
    color: var(--primary-color);
    border-color: var(--border-color);
    padding: var(--spacing-sm) var(--spacing-md);
}

.pagination-custom .page-link:hover {
    background-color: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.pagination-custom .page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* ===== FOOTER ===== */
.footer-main {
    margin-top: auto;
}

.footer-title {
    color: var(--white);
    font-family: var(--font-heading);
    font-weight: 700;
    margin-bottom: var(--spacing-md);
}

.footer-subtitle {
    color: var(--accent-color);
    font-weight: 600;
    margin-bottom: var(--spacing-md);
}

.footer-text {
    color: #adb5bd;
    line-height: 1.6;
}

.footer-links li {
    margin-bottom: var(--spacing-xs);
}

.footer-links a {
    color: #adb5bd;
    text-decoration: none;
    transition: var(--transition-fast);
}

.footer-links a:hover {
    color: var(--white);
}

.social-links a {
    display: inline-block;
    width: 40px;
    height: 40px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    text-align: center;
    line-height: 40px;
    transition: var(--transition-fast);
}

.social-links a:hover {
    background-color: var(--primary-color);
    transform: translateY(-3px);
}

.footer-divider {
    border-color: rgba(255, 255, 255, 0.1);
    margin: var(--spacing-xl) 0 var(--spacing-lg);
}

.copyright-text {
    color: #adb5bd;
    font-size: var(--font-size-sm);
}

/* ===== TORNA SU ===== */
.btn-back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 1000;
}

.btn-back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.btn-back-to-top:hover {
    background-color: var(--accent-color);
    transform: translateY(-3px);
}

/* ===== COOKIE CONSENT ===== */
.cookie-consent {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--secondary-color);
    color: var(--white);
    padding: var(--spacing-md) 0;
    z-index: 1050;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .hero-section {
        padding: var(--spacing-xl) 0;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .recipe-meta-info {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .procedure-step {
        padding-left: 2.5rem;
    }
    
    .social-share {
        flex-direction: column;
    }
    
    .filter-checkboxes {
        justify-content: center;
    }
    
    .search-input {
        min-width: auto;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .header-main,
    .footer-main,
    .social-share,
    .btn-back-to-top,
    .cookie-consent {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
        color: black;
        background: white;
    }
    
    .recipe-content {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .recipe-title {
        font-size: 24pt;
        margin-bottom: 20pt;
    }
    
    .ingredients-list li,
    .procedure-step {
        page-break-inside: avoid;
    }
}

/* ===== UTILITIES ===== */
.text-primary {
    color: var(--primary-color) !important;
}

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

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

.shadow-custom {
    box-shadow: var(--shadow) !important;
}

.rounded-lg {
    border-radius: var(--border-radius-lg) !important;
}

.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ===== ADMIN ACTIONS ===== */

/* Pulsanti amministrativi nell'header delle pagine */
.admin-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.admin-actions .btn {
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.admin-actions .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.admin-actions .btn-warning {
    background-color: #f39c12;
    border-color: #f39c12;
    color: white;
}

.admin-actions .btn-warning:hover {
    background-color: #e67e22;
    border-color: #e67e22;
}

.admin-actions .btn-danger {
    background-color: #e74c3c;
    border-color: #e74c3c;
}

.admin-actions .btn-danger:hover {
    background-color: #c0392b;
    border-color: #c0392b;
}

.admin-actions .btn-success {
    background-color: #27ae60;
    border-color: #27ae60;
}

.admin-actions .btn-success:hover {
    background-color: #229954;
    border-color: #229954;
}

/* Pulsanti amministrativi nelle card */
.admin-actions-card {
    padding-top: 0.75rem;
    border-top: 1px solid #f8f9fa;
    margin-top: 0.75rem;
}

.admin-actions-card .btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

/* Overlay pulsanti nelle griglie */
.admin-actions-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    gap: 4px;
}

.recipe-card-wrapper:hover .admin-actions-overlay,
.recipe-card:hover .admin-actions-overlay {
    opacity: 1;
}

.admin-actions-overlay .btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.4rem;
    border-radius: 4px;
    backdrop-filter: blur(5px);
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.admin-actions-overlay .btn:hover {
    background-color: rgba(255, 255, 255, 1);
    transform: scale(1.05);
}

.admin-actions-overlay .btn-warning {
    color: #f39c12;
}

.admin-actions-overlay .btn-warning:hover {
    background-color: #f39c12;
    color: white;
}

.admin-actions-overlay .btn-danger {
    color: #e74c3c;
}

.admin-actions-overlay .btn-danger:hover {
    background-color: #e74c3c;
    color: white;
}

/* Badge admin per indicare stato di autenticazione */
.admin-badge {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
    animation: pulse-admin 2s infinite;
}

@keyframes pulse-admin {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Responsive admin actions */
@media (max-width: 768px) {
    .admin-actions {
        flex-direction: column;
        gap: 0.25rem;
        align-items: stretch;
    }
    
    .admin-actions .btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    
    .admin-actions-overlay {
        position: static;
        opacity: 1;
        margin-top: 0.5rem;
        justify-content: center;
    }
}

@media (max-width: 576px) {
    .admin-actions {
        margin-top: 1rem;
    }
    
    .admin-actions .btn {
        width: 100%;
        text-align: center;
    }
}
