* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    position: relative;
}

.selector-dieta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.selector-dieta-label {
    font-size: 0.95em;
    opacity: 0.95;
}

.btn-dieta {
    padding: 8px 18px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    transition: all 0.25s ease;
}

.btn-dieta:hover {
    background: rgba(255, 255, 255, 0.35);
    border-color: white;
}

.btn-dieta.active {
    background: rgba(255, 255, 255, 0.9);
    color: #667eea;
    border-color: white;
}

.header-buttons {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    gap: 10px;
}

.btn-editar-dieta,
.btn-limpiar {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-editar-dieta:hover,
.btn-limpiar:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.btn-limpiar {
    background: rgba(220, 53, 69, 0.3);
    border-color: rgba(220, 53, 69, 0.8);
}

.btn-limpiar:hover {
    background: rgba(220, 53, 69, 0.5);
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

/* Barra de ordenación */
.ordenacion-barra {
    background: white;
    border-radius: 10px;
    padding: 15px 20px;
    margin-bottom: 25px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.ordenacion-titulo {
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
}

.ordenacion-items {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.ordenacion-item-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ordenacion-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #667eea;
}

.ordenacion-item {
    background: #667eea;
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: move;
    font-weight: 600;
    font-size: 0.9em;
    user-select: none;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ordenacion-item:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.ordenacion-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.ordenacion-item .drag-icon {
    font-size: 0.8em;
    opacity: 0.7;
}

.dias-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 16px;
}

.dia-card {
    background: white;
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.18);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    cursor: move;
}

.dia-card.dia-pasado {
    opacity: 0.5;
}

.dia-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
}

.dia-card.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.dia-header {
    border-bottom: 2px solid #667eea;
    padding-bottom: 6px;
    margin-bottom: 6px;
}

.dia-header h2 {
    font-size: 1.25em;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.drag-handle {
    cursor: grab;
    color: #667eea;
    font-size: 1.2em;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.tipo-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.7em;
    font-weight: bold;
    margin-left: 10px;
}

.tipo-badge.entreno {
    background: #4CAF50;
    color: white;
}

.tipo-badge.no-entreno {
    background: #FF9800;
    color: white;
}

.comidas-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.comida-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 6px 10px;
    border-left: 3px solid #667eea;
}

.comida-titulo {
    font-size: 1em;
    color: #667eea;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
    cursor: pointer;
}

.comida-colapsada .comida-contenido {
    display: none;
}

.comida-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    transition: transform 0.2s ease;
}

.comida-colapsada .comida-toggle-icon {
    transform: rotate(-90deg);
}

.comida-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-generar-receta {
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.btn-generar-receta:hover {
    background: #ee5a52;
    transform: scale(1.1);
}

.btn-generar-receta:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.btn-add-ingrediente-toggle {
    background: #28a745;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.btn-add-ingrediente-toggle:hover {
    background: #218838;
    transform: scale(1.1);
}

.btn-toggle-alternativa {
    background: #17a2b8;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.btn-toggle-alternativa:hover {
    background: #138496;
    transform: scale(1.1);
}

.alternativa-badge {
    font-size: 0.7em;
    background: #ffc107;
    color: #333;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: normal;
}

.ingredientes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ingrediente-item {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px;
    border-radius: 5px;
    transition: background 0.2s ease;
    width: 100%;
}

.checkbox-label:hover {
    background: rgba(102, 126, 234, 0.1);
}

.ingrediente-checkbox {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    cursor: pointer;
    accent-color: #667eea;
}

.ingrediente-texto {
    flex: 1;
    font-size: 0.95em;
    color: #555;
}

.ingrediente-checkbox:checked + .ingrediente-texto {
    background: #fff3cd;
    padding: 4px 8px;
    border-radius: 5px;
    font-weight: 600;
    color: #856404;
    border: 2px solid #ffc107;
}

.alternativa-container {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px dashed #ddd;
}

.alternativa-label {
    display: block;
    font-size: 0.9em;
    color: #666;
    margin-bottom: 8px;
    font-weight: 600;
}

.alternativa-input-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.alternativa-input {
    flex: 1;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9em;
    transition: border-color 0.3s ease;
}

.alternativa-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-add-ingrediente {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2em;
    font-weight: bold;
    transition: background 0.3s ease;
}

.btn-add-ingrediente:hover {
    background: #5568d3;
}

.ingredientes-alternativos-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ingrediente-alternativo-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: #e7f3ff;
    border-radius: 5px;
    border-left: 3px solid #667eea;
}

.ingrediente-alternativo-texto {
    flex: 1;
    font-size: 0.9em;
    color: #333;
}

.btn-remove-ingrediente {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background 0.3s ease;
}

.btn-remove-ingrediente:hover {
    background: #c82333;
}

.btn-remove-ingrediente-comida {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.8em;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.btn-remove-ingrediente-comida:hover {
    background: #c82333;
}

.añadir-ingrediente-container {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #ddd;
}

.añadir-ingrediente-input {
    flex: 1;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 0.9em;
    transition: border-color 0.3s ease;
}

.añadir-ingrediente-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.btn-add-ingrediente-comida {
    padding: 8px 15px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: background 0.3s ease;
}

.btn-add-ingrediente-comida:hover {
    background: #218838;
}

/* Lista de compra */
.lista-compra-container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-top: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.lista-compra-header {
    border-bottom: 3px solid #667eea;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.lista-compra-header h2 {
    font-size: 1.8em;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.lista-compra-vacia {
    text-align: center;
    padding: 40px;
    color: #999;
    font-style: italic;
}

.lista-compra-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lista-compra-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.lista-compra-item:hover {
    transform: translateX(5px);
}

.lista-compra-item.comprado {
    opacity: 0.5;
    text-decoration: line-through;
}

.lista-compra-item.comprado .lista-compra-ingrediente {
    color: #999;
}

.lista-compra-ingrediente {
    flex: 1;
    font-size: 1em;
    color: #333;
    font-weight: 500;
}

.lista-compra-dia {
    background: #667eea;
    color: white;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    font-weight: 600;
    margin-left: 15px;
}

.lista-compra-para {
    background: #764ba2;
    color: white;
    padding: 5px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
    margin-left: 10px;
}

/* Modal de edición de dieta */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-receta {
    max-width: 900px;
}

.receta-content {
    padding: 20px 0;
    line-height: 1.8;
    color: #333;
}

.receta-content h3 {
    color: #667eea;
    margin-top: 20px;
    margin-bottom: 10px;
}

.receta-content ul, .receta-content ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.receta-content li {
    margin-bottom: 8px;
}

.receta-content p {
    margin-bottom: 15px;
}

.receta-loading {
    text-align: center;
    padding: 40px;
    color: #667eea;
    font-size: 1.1em;
}

.receta-error {
    color: #dc3545;
    padding: 20px;
    background: #f8d7da;
    border-radius: 8px;
    border-left: 4px solid #dc3545;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 15px;
}

.modal-header h2 {
    margin: 0;
    color: #333;
}

.btn-close-modal {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s ease;
}

.btn-close-modal:hover {
    background: #c82333;
}

.modal-textarea {
    width: 100%;
    min-height: 400px;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    resize: vertical;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-modal {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-save {
    background: #28a745;
    color: white;
}

.btn-save:hover {
    background: #218838;
}

.btn-cancel {
    background: #6c757d;
    color: white;
}

.btn-cancel:hover {
    background: #5a6268;
}

/* Responsive */
@media (max-width: 768px) {
    .dias-container {
        grid-template-columns: 1fr;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .btn-editar-dieta {
        position: static;
        margin-top: 15px;
    }
    
    .lista-compra-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .lista-compra-dia {
        margin-left: 0;
        margin-top: 8px;
    }
    
    .modal-content {
        width: 95%;
        padding: 20px;
    }
}

