:root {
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --primary-color: #2ecc71;
    --secondary-color: #3498db;
    --text-color: #34495e;
    --header-color: #2c3e50;
    --border-color: #e9ecef;
    --shadow: 0 10px 20px rgba(0,0,0,0.05);
    --border-radius: 16px;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 24px;
}

body.modal-open {
    overflow: hidden;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-family: 'Pacifico', cursive;
    color: var(--primary-color);
    font-size: 3rem;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

header p {
    font-size: 1.1rem;
    color: #7f8c8d;
}

/* View Switcher */
.view-switcher {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    background-color: var(--card-bg);
    border-radius: 50px;
    padding: 5px;
    box-shadow: var(--shadow);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}
.view-switcher button {
    padding: 10px 25px;
    border: none;
    background-color: transparent;
    color: var(--text-color);
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
}
.view-switcher button.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 4px 10px rgba(46, 204, 113, 0.3);
}

.view { display: none; }
.view.active { display: block; }

/* Planner View */
#createPlanView {
    display: none;
    grid-template-columns: 300px 1fr;
    gap: 30px;
    align-items: flex-start;
}
#createPlanView.active {
    display: grid;
}

#recipeLibrary {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    height: 80vh;
    overflow-y: auto;
    position: sticky;
    top: 20px;
}
#recipeLibrary h2, #myPricesView h2, #recipeLibraryView h2 {
    margin-top: 0; text-align: center; color: var(--header-color);
}
#recipeSearch, #fullLibrarySearch {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    margin-bottom: 20px;
    box-sizing: border-box;
}

.recipe-card-lib {
    padding: 15px;
    background-color: var(--bg-color);
    border-radius: 12px;
    margin-bottom: 10px;
    cursor: grab;
    border-left: 5px solid var(--primary-color);
}
.recipe-card-lib h4 { margin: 0 0 5px 0; }
.recipe-card-lib p { margin: 0; font-size: 0.8rem; color: #7f8c8d; }

#plannerCalendar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}
.calendar-day {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}
.calendar-day-header {
    padding: 10px;
    font-weight: 700;
    text-align: center;
    background-color: var(--header-color);
    color: white;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}
.meal-slot {
    padding: 10px;
    min-height: 100px;
    border-top: 1px solid var(--border-color);
}
.meal-slot.drag-over {
    background-color: #e8f8f5;
}
.meal-slot .recipe-card-lib {
    cursor: default;
}
.meal-slot h5 {
    margin: 0 0 10px 0;
    color: var(--secondary-color);
}

.planner-actions {
    margin-top: 20px;
    text-align: center;
}

@media (max-width: 900px) {
    #createPlanView {
        grid-template-columns: 1fr;
    }
    #recipeLibrary {
        height: auto;
        max-height: 40vh;
        position: static;
    }
}

/* Price Catalog View */
#myPricesView {
    background-color: var(--card-bg);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}
.price-catalog-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}
.price-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-color: var(--bg-color);
    padding: 15px;
    border-radius: 12px;
}
.price-item label {
    font-weight: 600;
}
.price-inputs {
    display: flex;
    gap: 8px;
}
.price-inputs input, .price-inputs select {
    width: 100%;
    padding: 8px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
}
.price-actions {
    text-align: center;
    margin-top: 30px;
}

/* Estilos para el selector de moneda */
.currency-selector-container {
    text-align: center;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.currency-selector { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.currency-selector select, .currency-selector-container select {
    padding: 8px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    font-weight: 600;
    background-color: white;
    cursor: pointer;
}

/* Full Recipe Library View */
#fullLibraryContent {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
}
.recipe-card-full {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.recipe-card-full-header {
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}
.recipe-card-full-header h3 {
    margin: 0;
    font-size: 1.5rem;
}
 .recipe-card-full-content {
    padding: 20px;
}


/* --- STYLES FOR THE "VIEW PLANS" MODE --- */
.selectors-container { display: flex; flex-direction: column; gap: 20px; margin-bottom: 30px; align-items: center; }
.top-controls { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; align-items: center; }
.portion-selector { display: flex; align-items: center; gap: 10px; font-weight: 600; }
#portionSelectorInput { width: 60px; padding: 8px; border-radius: 8px; border: 2px solid var(--border-color); text-align: center; font-weight: 600; }
.action-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.action-btn { padding: 10px 20px; background: var(--secondary-color); color: white; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; transition: all 0.3s ease; }
.action-btn:hover { background: #2980b9; box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3); }
#planSelector { padding: 10px 15px; border-radius: 8px; border: 2px solid var(--border-color); font-weight: 600; background-color: white; min-width: 250px; cursor: pointer; }
.day-selector { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.day-selector button { padding: 10px 20px; border: 2px solid var(--border-color); background-color: var(--card-bg); color: var(--text-color); border-radius: 50px; cursor: pointer; font-weight: 600; font-size: 0.9rem; transition: all 0.3s ease; }
.day-selector button:hover { background-color: var(--primary-color); color: white; border-color: var(--primary-color); }
.day-selector button.active { background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)); color: white; border-color: var(--primary-color); box-shadow: 0 4px 10px rgba(46, 204, 113, 0.3); }
.week-grid { display: grid; justify-items: center; position: relative; min-height: 100px; }
.loader { border: 4px solid var(--border-color); border-top: 4px solid var(--primary-color); border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.day-card { background: var(--card-bg); border-radius: var(--border-radius); box-shadow: var(--shadow); overflow: hidden; width: 100%; max-width: 500px; }
.day-header { padding: 16px 20px; background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)); color: white; font-weight: 700; font-size: 1.25rem; text-align: center; }
.meal { padding: 20px; border-bottom: 1px solid var(--border-color); cursor: pointer; }
.meal:last-child { border-bottom: none; }
.meal-header { display: flex; justify-content: space-between; align-items: center; }
.meal-header h3 { margin: 0; font-size: 1.1rem; color: var(--header-color); font-weight: 600; }
.meal-header span { font-size: 0.9rem; color: #95a5a6; text-align: right; }
.meal-header .toggle-icon { transition: transform 0.3s ease; font-weight: bold; margin-left: 10px; }
.meal.active .toggle-icon { transform: rotate(180deg); }
.recipe-details { max-height: 0; overflow: hidden; transition: max-height 0.4s ease-out; }
.recipe-details.show { max-height: 2500px; transition: max-height 0.8s ease-in; }
.recipe-content { padding-top: 20px; display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 600px) { .recipe-content { grid-template-columns: 1fr 1fr; } }
.info-card, .chart-card, .details-section { background-color: var(--bg-color); padding: 16px; border-radius: 12px; border: 1px solid var(--border-color); }
.details-section { grid-column: 1 / -1; }
.chart-container { position: relative; height: 200px; width: 100%; }
.details-section h4, .info-card h4, .chart-card h4 { margin-top: 0; color: var(--secondary-color); border-bottom: 2px solid var(--primary-color); padding-bottom: 8px; margin-bottom: 12px; }
.info-card p { margin: 0; line-height: 1.6; }
.info-card strong { color: var(--header-color); }
.details-section ul, .details-section ol { padding-left: 20px; margin: 0; }
.details-section li { margin-bottom: 8px; line-height: 1.6; }
.shopping-list-btn { display: block; width: calc(100% - 40px); margin: 20px; padding: 12px; background: linear-gradient(135deg, #1abc9c, #16a085); color: white; border: none; border-radius: 10px; font-weight: 600; font-size: 1rem; cursor: pointer; transition: all 0.3s ease; }
.shopping-list-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 12px rgba(22, 160, 133, 0.3); }

/* --- MODAL STYLES --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.6); display: flex; justify-content: center; align-items: center; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; z-index: 1000; }
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal-content { background-color: white; padding: 30px; border-radius: var(--border-radius); width: 90%; max-width: 600px; max-height: 80vh; overflow-y: auto; transform: translateY(-50px); transition: transform 0.3s ease; }
.modal-overlay.show .modal-content { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 15px; margin-bottom: 20px; }
.modal-header h2 { margin: 0; color: var(--header-color); }
.close-modal { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #95a5a6; }
.modal-options { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-options .include-check { display: flex; gap: 10px; align-items: center; font-size: 0.9rem; }
.modal-options input { cursor: pointer; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions button { padding: 8px 12px; font-size: 0.8rem; border-radius: 6px; }
.shopping-list-category h3, .prep-step h3 { color: var(--primary-color); margin-top: 20px; margin-bottom: 10px; }
.shopping-list-category ul { list-style: none; padding: 0; }
.shopping-list-category li { display: flex; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border-color); }
.shopping-list-category input[type="checkbox"] { margin-right: 12px; width: 18px; height: 18px; cursor: pointer; }
.shopping-list-category label { flex-grow: 1; }
.shopping-list-category label.checked { text-decoration: line-through; color: #bdc3c7; }
.list-item-cost { font-size: 0.9rem; color: #7f8c8d; margin-left: auto; padding-left: 10px; }
.shopping-list-total { text-align: right; font-size: 1.2rem; font-weight: bold; margin-top: 20px; color: var(--header-color); }
.prep-step { padding-bottom: 15px; margin-bottom: 15px; border-bottom: 1px solid var(--border-color); }
.prep-step:last-child { border-bottom: none; }
.prep-step p { margin: 5px 0; }
.prep-step strong { color: var(--header-color); }
.shopping-list-category h3, .prep-step h3 { 
    color: var(--primary-color); 
    margin-top: 20px; 
    margin-bottom: 10px;
    border-bottom: 2px solid var(--border-color); /* Añadido para separar visualmente */
    padding-bottom: 5px; /* Añadido para separar visualmente */
}

/* CAMBIO: Estilos para la subcategoría */
.shopping-list-subcategory {
    margin-left: 15px; /* Indentación para mostrar jerarquía */
    margin-bottom: 15px;
}

.shopping-list-subcategory h4 {
    margin-top: 10px;
    margin-bottom: 8px;
    font-size: 1rem; /* Un poco más pequeño que el h3 */
    color: var(--secondary-color); /* Color secundario para diferenciar */
    font-weight: 600;
}

.shopping-list-category ul { list-style: none; padding: 0; }
@media print { body * { visibility: hidden; } .modal-overlay, .modal-overlay * { visibility: visible; } .modal-overlay { position: absolute; left: 0; top: 0; background-color: white; height: auto; overflow: visible; } .modal-content { box-shadow: none; border: none; width: 100%; max-width: 100%; max-height: none; padding: 0; } .modal-header, .modal-options, .modal-actions, .shopping-list-category input, .list-item-cost { display: none; } .shopping-list-category label.checked { text-decoration: none; color: var(--text-color); } }
