/**
 * Nutrietiqueta Step 1 - Formulario Moderno v2.0
 * Requiere: nutri-variables.css
 */

/* Variables adicionales específicas del Step 1 */
:root {
    --nutri-step1-max-width: 1000px;
    --nutri-step1-padding: 2rem;
    --nutri-step1-gap: 1.5rem;
    --nutri-step1-border-radius: 12px;
    --nutri-step1-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    --nutri-step1-shadow-hover: 0 8px 12px rgba(0, 0, 0, 0.1);
}

/* Container principal */
.nutri-step1-container {
    width: 100%;
    max-width: var(--nutri-step1-max-width);
    margin: 0 auto;
    padding: var(--nutri-step1-padding);
    font-family: var(--nutri-font-body);
}

/* Secciones con diseño moderno */
.nutri-step1-section {
    margin-bottom: var(--nutri-step1-gap);
    padding: var(--nutri-step1-gap);
    background: white;
    border: 1px solid var(--nutri-gray-200);
    border-radius: var(--nutri-step1-border-radius);
    box-shadow: var(--nutri-step1-shadow);
    transition: all 0.3s ease;
}

.nutri-step1-section:hover {
    box-shadow: var(--nutri-step1-shadow-hover);
    transform: translateY(-1px);
}

/* Títulos de sección */
.nutri-step1-section h3 {
    margin: 0 0 var(--nutri-step1-gap) 0;
    color: var(--nutri-gray-900);
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--nutri-gray-100);
}

.nutri-step1-section h3::before {
    content: '';
    width: 4px;
    height: 24px;
    background: linear-gradient(135deg, var(--nutri-primary), var(--nutri-primary-600));
    border-radius: 2px;
}

/* Grid de datos del producto */
.nutri-recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--nutri-step1-gap);
    margin-bottom: var(--nutri-step1-gap);
}

.nutri-recipe-col {
    display: flex;
    flex-direction: column;
}

/* Campos de formulario modernos */
.nutri-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nutri-field label {
    font-weight: 500;
    color: var(--nutri-gray-700);
    font-size: 0.875rem;
}

.nutri-field input,
.nutri-field select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--nutri-gray-200);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: white;
}

.nutri-field input:focus,
.nutri-field select:focus {
    outline: none;
    border-color: var(--nutri-primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.nutri-field input::placeholder {
    color: var(--nutri-gray-400);
}

/* Sección de ingredientes con diseño mejorado */
.nutri-ingredient-selector {
    position: relative;
}

.nutri-ingredients-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.nutri-ingredients-table thead {
    background: var(--nutri-gray-50);
    border-bottom: 2px solid var(--nutri-gray-200);
}

.nutri-ingredients-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--nutri-gray-700);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nutri-ingredients-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--nutri-gray-100);
}

.nutri-ingredients-table tbody tr:hover {
    background: var(--nutri-gray-50);
}

.nutri-ingredients-table tbody tr:last-child td {
    border-bottom: none;
}

/* Autocomplete de ingredientes */
.nutri-autocomplete-wrapper {
    position: relative;
}

.nutri-ingredient-search {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--nutri-gray-200);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.nutri-ingredient-search:focus {
    outline: none;
    border-color: var(--nutri-primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.nutri-autocomplete-wrapper {
    position: relative;
    z-index: 1;
}

.nutri-autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--nutri-gray-200);
    border-radius: 8px;
    box-shadow: var(--nutri-step1-shadow);
    max-height: 200px;
    overflow-y: auto;
    z-index: 9999;
    display: none;
    /* Asegurar visibilidad */
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
}

.nutri-autocomplete-results.show {
    display: block !important;
}

.nutri-result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--nutri-gray-100);
    transition: background 0.2s ease;
}

.nutri-result-item:hover {
    background: var(--nutri-primary-50);
}

.nutri-result-item:last-child {
    border-bottom: none;
}

.nutri-result-name {
    font-weight: 500;
    color: var(--nutri-gray-900);
}

.nutri-result-alias {
    font-size: 0.75rem;
    color: var(--nutri-gray-500);
    margin-top: 0.25rem;
}

.nutri-no-results {
    padding: 1rem;
    text-align: center;
    color: var(--nutri-gray-500);
    font-size: 0.875rem;
}

/* Inputs de cantidad y unidad */
.nutri-ingredient-amount,
.nutri-ingredient-unit {
    width: 100%;
    padding: 0.5rem;
    border: 2px solid var(--nutri-gray-200);
    border-radius: 6px;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.nutri-ingredient-amount:focus,
.nutri-ingredient-unit:focus {
    outline: none;
    border-color: var(--nutri-primary);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.1);
}

/* Botón de eliminar fila */
.nutri-remove-row {
    background: var(--nutri-error);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.nutri-remove-row:hover {
    background: #dc2626;
    transform: scale(1.05);
}

/* Botón agregar ingrediente */
.nutri-add-row-container {
    margin-top: 1rem;
    text-align: center;
}

#nutri_add_ingredient_row {
    background: var(--nutri-primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

#nutri_add_ingredient_row:hover {
    background: var(--nutri-primary-600);
    transform: translateY(-1px);
    box-shadow: var(--nutri-step1-shadow);
}

/* Indicador de peso total */
.nutri-weight-indicator {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--nutri-primary-50);
    border: 2px solid var(--nutri-primary-200);
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    color: var(--nutri-primary-700);
}

.nutri-weight-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--nutri-primary);
}

/* Cards de método de cocción (ya definidos en nutri-components.css) */
/* Se mantiene la referencia para consistencia */

/* Slider de rendimiento (ya definido en nutri-components.css) */
/* Se mantiene la referencia para consistencia */

/* Botones de acción del formulario */
.nutri-step1-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--nutri-gray-200);
}

.nutri-clear-form {
    background: white;
    color: var(--nutri-gray-600);
    border: 2px solid var(--nutri-gray-300);
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nutri-clear-form:hover {
    background: var(--nutri-gray-50);
    border-color: var(--nutri-gray-400);
}

.nutri-save-step1 {
    background: var(--nutri-primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.nutri-save-step1:hover {
    background: var(--nutri-primary-600);
    transform: translateY(-1px);
    box-shadow: var(--nutri-step1-shadow);
}

/* Mensajes de validación */
.nutri-validation-error {
    background: #fef2f2;
    border: 2px solid #fecaca;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    color: #dc2626;
}

.nutri-validation-error h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
}

.nutri-validation-error ul {
    margin: 0;
    padding-left: 1.5rem;
}

.nutri-validation-error li {
    margin-bottom: 0.25rem;
}

/* Responsive */
@media (max-width: 768px) {
    :root {
        --nutri-step1-padding: 1rem;
        --nutri-step1-gap: 1rem;
    }
    
    .nutri-recipe-grid {
        grid-template-columns: 1fr;
    }
    
    .nutri-step1-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .nutri-step1-actions button {
        width: 100%;
    }
    
    .nutri-ingredients-table {
        font-size: 0.875rem;
    }
    
    .nutri-ingredients-table th,
    .nutri-ingredients-table td {
        padding: 0.5rem;
    }
    
    .nutri-cooking-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .nutri-cooking-cards {
        grid-template-columns: 1fr;
    }
    
    .nutri-step1-section {
        padding: 1rem;
    }
}

/* Animaciones suaves */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nutri-ingredient-row {
    animation: fadeIn 0.3s ease;
}

/* Estados de carga */
.nutri-loading {
    opacity: 0.6;
    pointer-events: none;
}

.nutri-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--nutri-primary);
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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